/** * Indicates if the status is a server error status, meaning "The server * failed to fulfill an apparently valid request". * * @return True if the status is a server error status. */ public boolean isServerError() { return isServerError(getCode()); }
/** * Indicates if the status is a server error status, meaning "The server * failed to fulfill an apparently valid request". * * @return True if the status is a server error status. */ public boolean isServerError() { return isServerError(getCode()); }
/** * Indicates if the status is a server error status, meaning "The server * failed to fulfill an apparently valid request". * * @return True if the status is a server error status. */ public boolean isServerError() { return isServerError(getCode()); }
/** * Indicates if the status is an error (client or server) status. * * @param code * The code of the status. * @return True if the status is an error (client or server) status. */ public static boolean isError(int code) { return isClientError(code) || isServerError(code) || isConnectorError(code); }
/** * Indicates if the status is an error (client or server) status. * * @param code * The code of the status. * @return True if the status is an error (client or server) status. */ public static boolean isError(int code) { return isClientError(code) || isServerError(code) || isConnectorError(code); }
/** * Indicates if the status is an error (client or server) status. * * @param code * The code of the status. * @return True if the status is an error (client or server) status. */ public static boolean isError(int code) { return isClientError(code) || isServerError(code) || isConnectorError(code) || isGlobalError(code); }
@Override public void storeRepresentation( Representation representation ) throws ResourceException { try { super.storeRepresentation( representation ); } catch ( ResourceException e ) { if ( Status.isServerError( e.getStatus().getCode() ) ) { handleError( e ); } throw e; } catch ( RuntimeException e ) { handleError( e ); throw e; } }
@Override public void removeRepresentations() throws ResourceException { try { super.removeRepresentations(); } catch ( ResourceException e ) { if ( Status.isServerError( e.getStatus().getCode() ) ) { handleError( e ); } throw e; } catch ( RuntimeException e ) { handleError( e ); throw e; } }
@Override public void acceptRepresentation( Representation representation ) throws ResourceException { try { super.acceptRepresentation( representation ); } catch ( ResourceException e ) { if ( Status.isServerError( e.getStatus().getCode() ) ) { handleError( e ); } throw e; } catch ( RuntimeException e ) { handleError( e ); throw e; } }
@Override public void storeRepresentation(Representation representation) throws ResourceException { try { super.storeRepresentation(representation); } catch (ResourceException e) { if (Status.isServerError(e.getStatus().getCode())) { handleError(e); } throw e; } catch (RuntimeException e) { handleError(e); throw e; } }
@Override public void removeRepresentations() throws ResourceException { try { super.removeRepresentations(); } catch (ResourceException e) { if (Status.isServerError(e.getStatus().getCode())) { handleError(e); } throw e; } catch (RuntimeException e) { handleError(e); throw e; } }
@Override public void acceptRepresentation(Representation representation) throws ResourceException { try { super.acceptRepresentation(representation); } catch (ResourceException e) { if (Status.isServerError(e.getStatus().getCode())) { handleError(e); } throw e; } catch (RuntimeException e) { handleError(e); throw e; } }
if (status.isServerError()) { level = Level.WARNING; } else if (status.isConnectorError()) {
@Override public Representation represent( Variant variant ) throws ResourceException { try { return super.represent( variant ); } catch ( ResourceException e ) { // NEXUS-4238, NEXUS-4290 // if it's server error based on HTTP Code, but NOT when Nexus throws a known 503 // (see org.sonatype.nexus.rest.AbstractResourceStoreContentPlexusResource.handleException(Request, Response, Exception)) final Status status = e.getStatus(); if ( status == null ) { handleError( e ); } else { final int code = status.getCode(); if ( Status.isServerError( code ) && Status.SERVER_ERROR_SERVICE_UNAVAILABLE.getCode() != code ) { handleError( e ); } } throw e; } catch ( RuntimeException e ) { handleError( e ); throw e; } }
@Override public Representation represent(Variant variant) throws ResourceException { try { return super.represent(variant); } catch (ResourceException e) { // NEXUS-4238, NEXUS-4290 // if it's server error based on HTTP Code, but NOT when Nexus throws a known 503 // (see org.sonatype.nexus.rest.AbstractResourceStoreContentPlexusResource.handleException(Request, Response, Exception)) final Status status = e.getStatus(); if (status == null) { handleError(e); } else { final int code = status.getCode(); if (Status.isServerError(code) && Status.SERVER_ERROR_SERVICE_UNAVAILABLE.getCode() != code) { handleError(e); } } throw e; } catch (RuntimeException e) { handleError(e); throw e; } }
/** * Invoked when an error or an exception is caught during initialization, * handling or releasing. By default, updates the responses's status with * the result of {@link org.restlet.service.StatusService#toStatus(Throwable, Resource)}. * * @param throwable * The caught error or exception. */ protected void doCatch(Throwable throwable) { Level level = Level.INFO; Status status = getStatusService().toStatus(throwable, this); if (status.isServerError()) { level = Level.SEVERE; } else if (status.isConnectorError()) { level = Level.INFO; } else if (status.isClientError()) { level = Level.FINE; } getLogger().log(level, "Exception or error caught in server resource", throwable); if (getResponse() != null) { getResponse().setStatus(status); Representation errorEntity = getStatusService().toRepresentation( status, this); getResponse().setEntity(errorEntity); } }