01: package org.bouncycastle.i18n;
02:
03: import java.util.Locale;
04:
05: /**
06: * Base class for all Exceptions with localized messages.
07: */
08: public class LocalizedException extends Exception {
09:
10: protected ErrorBundle message;
11: private Throwable cause;
12:
13: /**
14: * Constructs a new LocalizedException with the specified localized message.
15: * @param message the {@link ErrorBundle} that contains the message for the exception
16: */
17: public LocalizedException(ErrorBundle message) {
18: super (message.getText(Locale.getDefault()));
19: this .message = message;
20: }
21:
22: /**
23: * Constructs a new LocalizedException with the specified localized message and cause.
24: * @param message the {@link ErrorBundle} that contains the message for the exception
25: * @param throwable the cause
26: */
27: public LocalizedException(ErrorBundle message, Throwable throwable) {
28: super (message.getText(Locale.getDefault()));
29: this .message = message;
30: this .cause = throwable;
31: }
32:
33: /**
34: * Returns the localized error message of the exception.
35: * @return the localized error message as {@link ErrorBundle}
36: */
37: public ErrorBundle getErrorMessage() {
38: return message;
39: }
40:
41: public Throwable getCause() {
42: return cause;
43: }
44: }
|