Spring Framework DefaultResponseErrorHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework DefaultResponseErrorHandler class.

This code example shows how to use the following methods:
import org.springframework.web.client.DefaultResponseErrorHandler; 
 
/** 
 * @author Roy Clarkson 
 */ 
public class GreenhouseErrorHandler extends DefaultResponseErrorHandler { 
 
} 
5
CodeRank
This code example shows how to use the following methods:
import org.springframework.social.ServerOverloadedException; 
import org.springframework.social.UncategorizedApiException; 
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestClientException;
 
public class WeiboErrorHandler extends DefaultResponseErrorHandler {
 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException {
		HttpStatus statusCode = response.getStatusCode();
		if (statusCode.series() == Series.SERVER_ERROR) {
			handleServerErrors(statusCode);
		} else if (statusCode.series() == Series.CLIENT_ERROR) {
			handleClientErrors(response);
		} 
 
		// if not otherwise handled, do default handling and wrap with 
		// UncategorizedApiException 
		try { 
			super.handleError(response);
4
CodeRank
This code example shows how to use the following methods:
import org.springframework.web.client.DefaultResponseErrorHandler;
 
import java.io.IOException;
import java.util.Map;
 
public class YammerErrorHandler extends DefaultResponseErrorHandler {
 
	private static final String RATE_LIMIT_EXCEEDED_MESSAGE_TEXT = "Rate limited due to excessive requests.";
	private static final String ERROR_MESSAGE_KEY = "message";
 
 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException {
		HttpStatus statusCode = response.getStatusCode();
		if (statusCode.series() == Series.SERVER_ERROR) {
			handleServerErrors(statusCode);
		} else if (statusCode.series() == Series.CLIENT_ERROR) {
			handleClientErrors(response);
		} 
 
4
CodeRank
This code example shows how to use the following methods:
import org.springframework.social.ResourceNotFoundException; 
import org.springframework.social.foursquare.api.FoursquareApiException; 
import org.springframework.social.foursquare.api.ParamErrorException; 
import org.springframework.web.client.DefaultResponseErrorHandler;
 
public class FoursquareErrorHandler extends DefaultResponseErrorHandler {
	 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException {
	    Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response);
	     
	    int code = Integer.valueOf(String.valueOf(errorDetails.get("code"))).intValue();
        String errorType = String.valueOf(errorDetails.get("errorType"));
        String message = String.valueOf(errorDetails.get("errorDetail"));
         
        handleFoursquareError(code, errorType, message);
         
        throw new FoursquareApiException(code, errorType, message);		
	} 
	 
4
CodeRank
This code example shows how to use the following methods:
/** 
 * Subclass of {@link DefaultResponseErrorHandler} that handles errors from Facebook's 
 * Graph API, interpreting them into appropriate exceptions. 
 * @author Craig Walls 
 */ 
class FacebookErrorHandler extends DefaultResponseErrorHandler {
 
	private final static Log logger = LogFactory.getLog(FacebookErrorHandler.class);
	private final static String FACEBOOK = "facebook";
 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException {
		Map<String, String> errorDetails = extractErrorDetailsFromResponse(response);
		if (errorDetails == null) {
			handleUncategorizedError(response, errorDetails);
		} 
		handleFacebookError(response.getStatusCode(), errorDetails);
		 
		// if not otherwise handled, do default handling and wrap with UncategorizedApiException 
		handleUncategorizedError(response, errorDetails);			
5
CodeRank
This code example shows how to use the following methods:
import java.util.Map;
 
/** 
 * @author Umut Utkan 
 */ 
public class SalesforceErrorHandler extends DefaultResponseErrorHandler {
 
    @Override 
    public void handleError(ClientHttpResponse response) throws IOException {
        Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response);
        if (errorDetails == null) {
            handleUncategorizedError(response, errorDetails);
        } 
 
        handleSalesforceError(response.getStatusCode(), errorDetails);
 
        // if not otherwise handled, do default handling and wrap with UncategorizedApiException 
        handleUncategorizedError(response, errorDetails);
    } 
 
4
CodeRank
This code example shows how to use the following methods:
/** 
 * Subclass of {@link DefaultResponseErrorHandler} that handles errors from VKontakte's 
 * API, interpreting them into appropriate exceptions. 
 * @author vkolodrevskiy 
 */ 
public class VKontakteErrorHandler extends DefaultResponseErrorHandler {
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException {
		HttpStatus statusCode = response.getStatusCode();
		if (statusCode.series() == HttpStatus.Series.SERVER_ERROR) {
			handleServerErrors(statusCode);
		} else if (statusCode.series() == HttpStatus.Series.CLIENT_ERROR) {
			handleClientErrors(response);
		} 
 
		// if not otherwise handled, do default handling and wrap with UncategorizedApiException 
		try { 
			super.handleError(response);
		} catch(Exception e) {
			throw new UncategorizedApiException("vkontakte", "Error consuming VKontakte REST API", e);
4
CodeRank
This code example shows how to use the following methods:
/** 
 * Custom error handler for handling Salesforce API specific error responses. 
 * 
 * @author Umut Utkan 
 */ 
public class ErrorHandler extends DefaultResponseErrorHandler {
 
    @Override 
    public void handleError(ClientHttpResponse response) throws IOException {
        if (response.getStatusCode().equals(HttpStatus.BAD_REQUEST)) {
            Map<String, String> error = extractErrorDetailsFromResponse(response);
            if ("unsupported_response_type".equals(error.get("error"))) {
                throw new OperationNotPermittedException(error.get("error_description"));
            } else if ("invalid_client_id".equals(error.get("error"))) {
                throw new InvalidAuthorizationException(error.get("error_description"));
            } else if ("invalid_request".equals(error.get("error"))) {
                throw new OperationNotPermittedException(error.get("error_description"));
            } else if ("invalid_client_credentials".equals(error.get("error"))) {
                throw new InvalidAuthorizationException(error.get("error_description"));
            } else if ("invalid_grant".equals(error.get("error"))) {
4
CodeRank
This code example shows how to use the following methods:
 */ 
public class VndErrorResponseErrorHandler extends DefaultResponseErrorHandler { 
 
	private ResponseExtractor<VndErrors> errorExtractor; 
 
	public VndErrorResponseErrorHandler(List<HttpMessageConverter<?>> messageConverters) { 
		errorExtractor = new HttpMessageConverterExtractor<VndErrors>(VndErrors.class, messageConverters); 
	} 
 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException { 
		VndErrors error = null; 
		try { 
			error = errorExtractor.extractData(response); 
		} 
		catch (Exception e) { 
			super.handleError(response); 
		} 
		throw new SpringXDException(error); 
	} 
4
CodeRank
This code example shows how to use the following methods:
import org.codehaus.jackson.type.TypeReference; 
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.social.instagram.api.InstagramApiException; 
import org.springframework.web.client.DefaultResponseErrorHandler;
 
public class InstagramErrorHandler extends DefaultResponseErrorHandler {
	 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException {				
	    Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response);
	    int code = Integer.valueOf(String.valueOf(errorDetails.get("code"))).intValue();
        String errorType = String.valueOf(errorDetails.get("error_type"));
        String message = String.valueOf(errorDetails.get("error_message"));
        throw new InstagramApiException(code, errorType, message);		
	} 
	 
	@SuppressWarnings("unchecked") 
    private Map<String, Object> extractErrorDetailsFromResponse(ClientHttpResponse response) throws IOException {
        ObjectMapper mapper = new ObjectMapper(new JsonFactory());
        Map<String, Object> responseMap = mapper.<Map<String, Object>>readValue(response.getBody(), new TypeReference<Map<String, Object>>() {});
4
CodeRank
See Code Examples for Spring Framework DefaultResponseErrorHandler Methods: