@Override public String getDeveloperMessage() { return error.getDeveloperMessage(); }
/** * 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(); }
/** * Retrieves the {@link ApiKey} instance pointed by this {@code apiKeyId} and accessible from the {@code * application} <p/> The ApiKey is retrieved from the {@link Application} passed as argument. <p/> This method * asserts that the ApiKey retrieved status is {@link ApiKeyStatus#ENABLED} and also that the status of the account * owner is {@link AccountStatus#ENABLED} * * @param apiKeyId - The id of the {@link ApiKey} embedded in the access token. */ protected ApiKey getTokenApiKey(HttpServletRequest request, String apiKeyId) throws OAuthException { try { return getEnabledApiKey(request, apiKeyId); } catch (ResourceException e) { OAuthErrorCode err = OAuthErrorCode.INVALID_CLIENT; String msg = e.getStormpathError().getDeveloperMessage(); throw new OAuthException(err, msg, e); } } }
/** * Retrieves the {@link ApiKey} instance pointed by this {@code apiKeyId} and accessible from the {@code * application} <p/> The ApiKey is retrieved from the {@link Application} passed as argument. <p/> This method * asserts that the ApiKey retrieved status is {@link ApiKeyStatus#ENABLED} and also that the status of the account * owner is {@link AccountStatus#ENABLED} * * @param apiKeyId - The id of the {@link ApiKey} embedded in the access token. */ protected ApiKey getTokenApiKey(HttpServletRequest request, String apiKeyId) throws OAuthException { try { return getEnabledApiKey(request, apiKeyId); } catch (ResourceException e) { OAuthErrorCode err = OAuthErrorCode.INVALID_CLIENT; String msg = e.getStormpathError().getDeveloperMessage(); throw new OAuthException(err, msg, e); } } }