public JaxbExceptionResponse(String requestUrl, Exception e, JaxbRequestStatus status) { this.url = requestUrl; this.status = status; initializeExceptionAndMessage(e); }
public void setCause(Exception cause) { this.cause = cause; if( cause != null ) { this.stackTrace = convertStackTraceToString(cause); } }
public void addException(Exception exception, int i, Command<?> cmd, JaxbRequestStatus status) { lazyInitResponseList(); this.responses.add(new JaxbExceptionResponse(exception, i, cmd, status)); }
if( response instanceof JaxbRestRequestException ) { JaxbRestRequestException exception = (JaxbRestRequestException) response; exceptionResponse = new JaxbExceptionResponse( exception.getUrl(), exception.getCause(), exception.getStatus()); exceptionResponse.setCommandName(cmdName); exceptionResponse.setIndex(0); exceptionResponse.setMessage(exception.getMessage()); } else if( response instanceof JaxbExceptionResponse ) { exceptionResponse = (JaxbExceptionResponse) response; String content = httpResponse.body(); htmlException = true; exceptionResponse = new JaxbExceptionResponse(); Document doc = Jsoup.parse(content); String body = doc.body().text(); exceptionResponse.setMessage(body); exceptionResponse.setUrl(httpRequest.getUri().toString()); exceptionResponse.setStackTrace(""); } else { if( responseStatus == 401 ) { throw new RemoteTaskException(exceptionResponse.getMessage(), exceptionResponse.getStackTrace()); default: if( exceptionResponse != null ) { if( ! htmlException ) { throw new RemoteApiException(exceptionResponse.getMessage(), exceptionResponse.getStackTrace()); } else {
@Test public void exceptionTest() throws Exception { Assume.assumeFalse(getType().equals(TestType.YAML)); JaxbExceptionResponse resp = new JaxbExceptionResponse(); resp.setMessage("error"); resp.setStatus(JaxbRequestStatus.SUCCESS); resp.setUrl("http://here"); RuntimeException re = new RuntimeException(); resp.setCause(re); testRoundTrip(resp); }
@Test public void genericResponseTest() throws Exception { JaxbGenericResponse resp = new JaxbGenericResponse(); resp.setMessage("error"); resp.setStatus(JaxbRequestStatus.SUCCESS); resp.setUrl("http://here"); testRoundTrip(resp); }
if( response instanceof JaxbExceptionResponse ) { JaxbExceptionResponse exceptionResponse = (JaxbExceptionResponse) response; throw new RemoteApiException(exceptionResponse.getMessage(), exceptionResponse.getStackTrace()); } else { return (T) response.getResult();
throw new RuntimeException(exceptionResponse.getMessage());
@Test public void exceptionTest() throws Exception { Assume.assumeFalse(getType().equals(TestType.YAML)); JaxbExceptionResponse resp = new JaxbExceptionResponse(); resp.setMessage("error"); resp.setStatus(JaxbRequestStatus.SUCCESS); resp.setUrl("http://here"); RuntimeException re = new RuntimeException(); resp.setCause(re); testRoundTrip(resp); }
@Test public void genericResponseTest() throws Exception { JaxbGenericResponse resp = new JaxbGenericResponse(); resp.setMessage("error"); resp.setStatus(JaxbRequestStatus.SUCCESS); resp.setUrl("http://here"); testRoundTrip(resp); }
throw new RuntimeException(exceptionResponse.getMessage());
public void addException(Exception exception, int i, Command<?> cmd, JaxbRequestStatus status) { lazyInitResponseList(); this.responses.add(new JaxbExceptionResponse(exception, i, cmd, status)); }
public JaxbExceptionResponse(Exception e, int i, Command<?> cmd, JaxbRequestStatus status) { super(i, cmd); initializeExceptionAndMessage(e); this.status = status; }
public void setCause(Exception cause) { this.cause = cause; this.stackTrace = convertStackTraceToString(cause); }
assertTrue( "Expected an exception response", resp instanceof JaxbExceptionResponse); String msg = ((JaxbExceptionResponse) resp).getMessage(); assertTrue( "Exception should reference incorrect user", msg.contains(otherUser) ); assertTrue( "Exception should reference correct/auth user", msg.contains(USER) ); assertTrue( "Expected an exception response", resp instanceof JaxbExceptionResponse); msg = ((JaxbExceptionResponse) resp).getMessage(); assertTrue( "Exception should reference correct/auth user", msg.contains(USER) ); assertTrue( "Exception should explain fault", msg.contains("null user id"));
public JaxbExceptionResponse(String requestUrl, Exception e, JaxbRequestStatus status) { this.url = requestUrl; this.status = status; initializeExceptionAndMessage(e); }
private void initializeExceptionAndMessage(Exception e) { this.cause = e; this.message = e.getClass().getSimpleName() + " thrown with message '" + e.getMessage() + "'"; if( e.getCause() != null ) { Throwable t = e.getCause(); this.message = t.getClass().getSimpleName() + " thrown with message '" + t.getMessage() + "'"; } this.stackTrace = convertStackTraceToString(e); }
public JaxbExceptionResponse(Exception e, int i, Command<?> cmd, JaxbRequestStatus status) { super(i, cmd); initializeExceptionAndMessage(e); this.status = status; }
private void initializeExceptionAndMessage(Exception e) { this.cause = e; this.message = e.getClass().getSimpleName() + " thrown with message '" + e.getMessage() + "'"; if( e.getCause() != null ) { Throwable t = e.getCause(); this.message = t.getClass().getSimpleName() + " thrown with message '" + t.getMessage() + "'"; } this.stackTrace = convertStackTraceToString(e); }