File |
Line |
org\jadira\cdt\exception\WrappedCheckedException.java |
40 |
org\jadira\cdt\exception\WrappedRuntimeException.java |
40 |
public WrappedCheckedException(String message, Throwable cause) {
super(message, cause);
}
/**
* Return the detail message, including the message from the Wrapped
* exception if there is one.
*/
@Override
public String getMessage() {
return constructMessage(super.getMessage(), getCause());
}
/**
* Constructs an exception String with the given message and incorporating the
* causing exception
* @param message The specific message
* @param cause The causing exception
* @return The exception String
*/
protected String constructMessage(String message, Throwable cause) {
if (cause != null) {
StringBuilder strBuilder = new StringBuilder();
if (message != null) {
strBuilder.append(message).append(": ");
}
strBuilder.append("Wrapped exception is {").append(cause);
strBuilder.append("}");
return strBuilder.toString();
} else {
return message;
}
}
/**
* Retrieves the ultimate root cause for this exception, or null
* @return The root cause
*/
public Throwable getRootCause() {
Throwable rootCause = null;
Throwable nextCause = getCause();
while (nextCause != null && !nextCause.equals(rootCause)) {
rootCause = nextCause;
nextCause = nextCause.getCause();
}
return rootCause;
}
/**
* Returns the next parent exception of the given type, or null
* @param exceptionType the exception type to match
* @param <E> The Exception type
* @return The matched exception of the target type, or null
*/
public <E extends Exception> E findWrapped(Class<E> exceptionType) {
if (exceptionType == null) {
return null;
}
Throwable cause = getCause();
while (true) {
if (cause == null) {
return null;
}
if (exceptionType.isInstance(cause)) {
@SuppressWarnings("unchecked") E matchedCause = (E) cause;
return matchedCause;
}
if (cause.getCause() == cause) {
return null;
}
if (cause instanceof WrappedRuntimeException) {
return ((WrappedRuntimeException) cause).findWrapped(exceptionType);
}
if (cause instanceof WrappedCheckedException) {
return ((WrappedCheckedException) cause).findWrapped(exceptionType);
}
cause = cause.getCause();
}
}
} |
File |
Line |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
136 |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
152 |
protected E164PhoneNumberWithExtension(String phoneNumber, CountryCode defaultCountryCode) {
try {
number = PHONE_NUMBER_UTIL.parse(phoneNumber, defaultCountryCode.toString());
} catch (NumberParseException e) {
throw new PhoneNumberParseException(
EX_PARSE_MSG_PREFIX + phoneNumber + "} for country {" + defaultCountryCode +"}", e);
} |
File |
Line |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
96 |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
119 |
}
try {
number = PHONE_NUMBER_UTIL.parse(e164PhoneNumber, "GB");
} catch (NumberParseException e) {
throw new PhoneNumberParseException(
EX_PARSE_MSG_PREFIX + e164PhoneNumber +"}", e);
} |
File |
Line |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
66 |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
229 |
this.number = PHONE_NUMBER_UTIL.parse(e164Builder.toString(), "GB");
} catch (NumberParseException e) {
throw new PhoneNumberParseException(
EX_PARSE_MSG_PREFIX + prototype.getNationalNumber() +"}", e); |
File |
Line |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
102 |
org\jadira\cdt\phonenumber\impl\E164PhoneNumberWithExtension.java |
158 |
EX_PARSE_MSG_PREFIX + e164PhoneNumber +"}", e);
}
if (extension != null) {
number.setExtension(extension);
}
} |