@Test public void testLoginFailure() { final GenericException f = new GenericException( "message", new Header[]{}, new BasicStatusLine(new ProtocolVersion("http", 1, 1), 403, "Forbidden")); assertTrue(new SwiftExceptionMappingService().map(f) instanceof AccessDeniedException); assertEquals("Access denied", new SwiftExceptionMappingService().map(f).getMessage()); assertEquals("Message. 403 Forbidden. Please contact your web hosting service provider for assistance.", new SwiftExceptionMappingService().map(f).getDetail()); }
@Override public BackgroundException map(final GenericException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); final StatusLine status = e.getHttpStatusLine(); if(null != status) { this.append(buffer, String.format("%d %s", status.getStatusCode(), status.getReasonPhrase())); } switch(e.getHttpStatusCode()) { case HttpStatus.SC_BAD_REQUEST: return new LoginFailureException(buffer.toString(), e); } return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(e.getHttpStatusCode(), buffer.toString())); }
SwiftExceptionMappingService extends AbstractExceptionMappingService<GenericException> { @Override public BackgroundException map(final GenericException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); final StatusLine status = e.getHttpStatusLine(); if(null != status) { this.append(buffer, String.format("%d %s", status.getStatusCode(), status.getReasonPhrase())); } switch(e.getHttpStatusCode()) { case HttpStatus.SC_BAD_REQUEST: return new LoginFailureException(buffer.toString(), e); } return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(e.getHttpStatusCode(), buffer.toString())); } }
SwiftExceptionMappingService extends AbstractExceptionMappingService<GenericException> { @Override public BackgroundException map(final GenericException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); final StatusLine status = e.getHttpStatusLine(); if(null != status) { this.append(buffer, String.format("%d %s", status.getStatusCode(), status.getReasonPhrase())); } switch(e.getHttpStatusCode()) { case HttpStatus.SC_BAD_REQUEST: return new LoginFailureException(buffer.toString(), e); } return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(e.getHttpStatusCode(), buffer.toString())); }  }
SwiftExceptionMappingService extends AbstractExceptionMappingService<GenericException> { @Override public BackgroundException map(final GenericException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); final StatusLine status = e.getHttpStatusLine(); if(null != status) { this.append(buffer, String.format("%d %s", status.getStatusCode(), status.getReasonPhrase())); } switch(e.getHttpStatusCode()) { case HttpStatus.SC_BAD_REQUEST: return new LoginFailureException(buffer.toString(), e); } return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(e.getHttpStatusCode(), buffer.toString())); }  @Override BackgroundException map(final GenericException e); }
SwiftExceptionMappingService extends AbstractExceptionMappingService<GenericException> { @Override public BackgroundException map(final GenericException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); final StatusLine status = e.getHttpStatusLine(); if(null != status) { this.append(buffer, String.format("%d %s", status.getStatusCode(), status.getReasonPhrase())); } switch(e.getHttpStatusCode()) { case HttpStatus.SC_BAD_REQUEST: return new LoginFailureException(buffer.toString(), e); } return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(e.getHttpStatusCode(), buffer.toString())); }  @Override BackgroundException map(final GenericException e);  }