public String parseErrorMessage ( HttpResponse httpResponse , JsonNode jsonNode ) { // If X_AMZN_ERROR_MESSAGE is present, prefer that. Otherwise check the JSON body. final String headerMessage = httpResponse . getHeader ( X_AMZN_ERROR_MESSAGE ) ; if ( headerMessage != null ) { return headerMessage ; } for ( String field : errorMessageJsonLocations ) { JsonNode value = jsonNode . get ( field ) ; if ( value != null && value . isTextual ( ) ) { return value . asText ( ) ; } } return null ; }
Parse the error message from the response .