1 package com.jdon.servicelocator; 2 3 7 public class ServiceLocatorException extends Exception { 8 private Exception exception; 9 10 15 public ServiceLocatorException(String message, Exception exception) { 16 super(message); 17 this.exception = exception; 18 return; 19 } 20 21 25 public ServiceLocatorException(String message) { 26 this(message, null); 27 return; 28 } 29 30 34 public ServiceLocatorException(Exception exception) { 35 this(null, exception); 36 return; 37 } 38 39 44 public Exception getException() { 45 return exception; 46 } 47 48 53 public Exception getRootCause() { 54 if (exception instanceof ServiceLocatorException) { 55 return ((ServiceLocatorException) exception).getRootCause(); 56 } 57 return exception == null ? this : exception; 58 } 59 60 public String toString() { 61 if (exception instanceof ServiceLocatorException) { 62 return ((ServiceLocatorException) exception).toString(); 63 } 64 return exception == null ? super.toString() : exception.toString(); 65 } 66 } 67 | Popular Tags |