/** * Get the Stormpath Error Code * Check http://docs.stormpath.com/errors/ for the list of Stormpath Error Codes * @return the code of the error */ @Override public int getCode() { return error.getCode(); }
protected boolean supports(Error error) { return supportedErrors.contains(error.getCode()); }
public void rethrow() throws InvalidSamlTokenException, SamlSessionTimeoutException { Error error = this.getStormpathError(); if (error.getCode() == 10100 || error.getCode() == 10101 || error.getCode() == 10102) { throw new InvalidSamlTokenException(error); } if (this.getStormpathError().getCode() == 12001) { throw new SamlSessionTimeoutException(error); } throw new IllegalStateException("error type is unrecognized: " + error.getCode()); }
/** * Converts this generic IDSite exception into one of the following corresponding checked exceptions: InvalidIDSiteTokenException, IDSiteSessionTimeoutException. * * @throws InvalidIDSiteTokenException * @throws IDSiteSessionTimeoutException */ public void rethrow() throws InvalidIDSiteTokenException, IDSiteSessionTimeoutException { Error error = this.getStormpathError(); if (error.getCode() == 10011 || error.getCode() == 10012 || error.getCode() == 11001 || error.getCode() == 11002 || error.getCode() == 11003 || error.getCode() == 11005 ) { throw new InvalidIDSiteTokenException(error); } if (this.getStormpathError().getCode() == 12001) { throw new IDSiteSessionTimeoutException(error); } if (this.getStormpathError().getCode() == 11005) { throw new IDSiteSessionTimeoutException(error); } throw new IllegalStateException("error type is unrecognized: " + error.getCode()); }
/** * Ensures the message used for the exception (i.e. exception.getMessage()) reports the {@code developerMessage} * returned by the Stormpath API Server. The regular Stormpath response body {@code message} field is targeted * at applicadtion end-users that could very likely be non-technical. Since an exception should be helpful to * developers, it is better to show a more technical message. * <p/> * Added as a fix for <a href="https://github.com/stormpath/stormpath-sdk-java/issues/28">Issue #28</a>. * * @param error the response Error. Cannot be null. * @return {@code error.getDeveloperMessage()} * @since 0.9.2 */ private static String buildExceptionMessage(Error error) { Assert.notNull(error, "Error argument cannot be null."); StringBuilder sb = new StringBuilder(); sb.append("HTTP ").append(error.getStatus()) .append(", Stormpath ").append(error.getCode()) .append(" (").append(error.getMoreInfo()).append(")"); String requestId = error.getRequestId(); if (Strings.hasText(requestId)) { sb.append(", RequestId ").append(error.getRequestId()); } return sb.append(": ").append(error.getDeveloperMessage()).toString(); }
private ErrorModel translateResourceException(HttpServletRequest request, ResourceException e) { return new ErrorModel.Builder() .setStatus(e.getStormpathError().getStatus()) .setMessage(getErrorMessage(request, "stormpath.web.errors." + e.getStormpathError().getCode(), e.getStormpathError().getMessage())) .build(); }
private ErrorModel translateResourceException(HttpServletRequest request, ResourceException e) { return new ErrorModel.Builder() .setStatus(e.getStormpathError().getStatus()) .setMessage(getErrorMessage(request, "stormpath.web.errors." + e.getStormpathError().getCode(), e.getStormpathError().getMessage())) .build(); }