protected String buildUploadFailedHtmlResponse(Throwable t, Request request, Response response) { try { handleException(request, response, t); } catch (ResourceException e) { getLogger().debug("Got error while uploading artifact", t); StringBuilder resp = new StringBuilder(); resp.append("<html><body><error>"); resp.append(StringEscapeUtils.escapeHtml(e.getMessage())); resp.append("</error></body></html>"); String forceSuccess = request.getResourceRef().getQueryAsForm().getFirstValue("forceSuccess"); if (!"true".equals(forceSuccess)) { response.setStatus(e.getStatus()); } return resp.toString(); } // We have an error at this point, can't get here return null; }
protected String buildUploadFailedHtmlResponse( Throwable t, Request request, Response response ) { try { handleException( request, response, t ); } catch ( ResourceException e ) { getLogger().debug( "Got error while uploading artifact", t ); StringBuffer resp = new StringBuffer(); resp.append( "<html><body><error>"); resp.append( StringEscapeUtils.escapeHtml( e.getMessage() )); resp.append( "</error></body></html>" ); String forceSuccess = request.getResourceRef().getQueryAsForm().getFirstValue( "forceSuccess" ); if ( !"true".equals( forceSuccess ) ) { response.setStatus( e.getStatus() ); } return resp.toString(); } // We have an error at this point, can't get here return null; }
/** * Prints the resource's representation. * * @param clientResource * The Restlet client resource. * @throws IOException * @throws ResourceException */ public static void get(ClientResource clientResource) throws IOException, ResourceException { try { clientResource.get().write(System.out); } catch (ResourceException e) { System.out.println("Error status: " + e.getStatus()); System.out.println("Error message: " + e.getMessage()); // Consume the response's entity which releases the connection clientResource.getResponseEntity().exhaust(); } }
response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( e.getStatus() );
response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( e.getStatus() );
response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( e.getStatus() );
response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( e.getStatus() );
response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( e.getStatus() );
response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( e.getStatus() );
String.format(Result.ERR_FAILURE.getFormattedMessage(), e.getMessage())) .build();
} catch (ResourceException e) { System.out.println("Error status: " + e.getStatus()); System.out.println("Error message: " + e.getMessage());