01: package it.geosolutions.utils.progress;
02:
03: /**
04: * Event launched when an exception occurrs. Percentage and message may be missing, in this case
05: * they will be -1 and the exception message (localized if available, standard otherwise)
06: *
07: * @author aaime
08: *
09: */
10: public class ExceptionEvent extends ProcessingEvent {
11:
12: private Exception exception;
13:
14: public ExceptionEvent(Object source, String message,
15: double percentage, Exception exception) {
16: super (source, message, percentage);
17: this .exception = exception;
18: }
19:
20: public ExceptionEvent(Object source, Exception exception) {
21: super (source, getMessageFromException(exception), -1);
22: this .exception = exception;
23: }
24:
25: public Exception getException() {
26: return exception;
27: }
28:
29: static String getMessageFromException(Exception exception) {
30: if (exception.getLocalizedMessage() != null)
31: return exception.getLocalizedMessage();
32: else
33: return exception.getMessage();
34: }
35:
36: }
|