2009-07-21 04:39:18 -04:00
|
|
|
/*
|
|
|
|
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
|
|
|
* Copyright (C) 2009 Mickael Guessant
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2009-04-27 19:03:58 -04:00
|
|
|
package davmail.exception;
|
|
|
|
|
|
|
|
import davmail.BundleMessage;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* I18 IOException subclass.
|
|
|
|
*/
|
|
|
|
public class DavMailException extends IOException {
|
|
|
|
private final BundleMessage message;
|
|
|
|
|
2009-08-14 03:57:51 -04:00
|
|
|
/**
|
|
|
|
* Create a DavMail exception with the given BundleMessage key and arguments.
|
|
|
|
*
|
2010-05-04 04:35:40 -04:00
|
|
|
* @param key message key
|
2009-08-14 03:57:51 -04:00
|
|
|
* @param arguments message values
|
|
|
|
*/
|
2009-04-27 19:03:58 -04:00
|
|
|
public DavMailException(String key, Object... arguments) {
|
2010-05-04 04:35:40 -04:00
|
|
|
this.message = new BundleMessage(key, arguments);
|
2009-04-27 19:03:58 -04:00
|
|
|
}
|
|
|
|
|
2009-08-14 03:57:51 -04:00
|
|
|
/**
|
|
|
|
* Get formatted message
|
|
|
|
*
|
2010-05-04 04:35:40 -04:00
|
|
|
* @return english formatted message
|
2009-08-14 03:57:51 -04:00
|
|
|
*/
|
2009-04-27 19:03:58 -04:00
|
|
|
@Override
|
|
|
|
public String getMessage() {
|
2010-05-04 04:35:40 -04:00
|
|
|
return message.formatLog();
|
2009-04-27 19:03:58 -04:00
|
|
|
}
|
|
|
|
|
2009-08-14 03:57:51 -04:00
|
|
|
/**
|
|
|
|
* Get formatted message using locale.
|
|
|
|
*
|
|
|
|
* @param locale locale
|
|
|
|
* @return localized formatted message
|
|
|
|
*/
|
2009-04-27 19:03:58 -04:00
|
|
|
public String getMessage(Locale locale) {
|
|
|
|
return message.format(locale);
|
|
|
|
}
|
|
|
|
|
2009-08-14 03:57:51 -04:00
|
|
|
/**
|
|
|
|
* Get internal exception BundleMessage.
|
|
|
|
*
|
|
|
|
* @return unformatted message
|
|
|
|
*/
|
2009-04-27 19:03:58 -04:00
|
|
|
public BundleMessage getBundleMessage() {
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
}
|