Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.paypal.base.rest;
 
PayPalException handles all exceptions related to REST services
 
public class PayPalRESTException extends Exception {

Serial Version ID
	private static final long serialVersionUID = 1L;

If source is com.paypal.base.exception.HttpErrorException, exception's response code value is copied
	private int responsecode;

If source is com.paypal.base.exception.HttpErrorException and response code is 400, error response content is converted to com.paypal.api.payments.Error object
	private Error details;
	public PayPalRESTException(String message) {
		super(message);
	}
	public PayPalRESTException(String messageThrowable throwable) {
		super(messagethrowable);
	}
	public PayPalRESTException(Throwable throwable) {
		super(throwable);
	}
	public int getResponsecode() {
		return ;
	}
	public void setResponsecode(int responsecode) {
		this. = responsecode;
	}
	public Error getDetails() {
		return ;
	}
	public void setDetails(Error details) {
		this. = details;
	}

Utility method that creates a PayPalRESTException object from com.paypal.base.exception.HttpErrorException. if com.paypal.base.exception.HttpErrorException contains 400 response code, error response is converted to com.paypal.api.payments.Error object.

Parameters:
httpErrorException com.paypal.base.exception.HttpErrorException thrown from API call
Returns:
	protected static PayPalRESTException createFromHttpErrorException(HttpErrorException httpErrorException){
		PayPalRESTException ppre = new PayPalRESTException(httpErrorException.getMessage(), httpErrorException);
		ppre.setResponsecode(httpErrorException.getResponsecode());
		if. == httpErrorException.getResponsecode() &&  httpErrorException.getErrorResponse()!=null){
			try{
				Error details = JSONFormatter.fromJSON(httpErrorException.getErrorResponse(), Error.class);	
				ppre.setDetails(details);
catch(Exception e){
			}
		}
		return ppre;
	}
New to GrepCode? Check out our FAQ X