public static GoCardlessApiException toException ( ApiErrorResponse error ) { switch ( error . getType ( ) ) { case GOCARDLESS : return new GoCardlessInternalException ( error ) ; case INVALID_API_USAGE : return new InvalidApiUsageException ( error ) ; case INVALID_STATE : return new InvalidStateException ( error ) ; case VALIDATION_FAILED : return new ValidationFailedException ( error ) ; } throw new IllegalStateException ( "Unknown error type: " + error . getType ( ) ) ; }
Maps an error response to an exception .