/** * Returns a representation for the given status.<br> * In order to customize the default representation, this method can be * overridden. By default it invokes * {@link #toRepresentation(Status, Request, Response)} * * @param status * The status to represent. * @param resource * The parent resource. * @return The representation of the given status. */ public Representation toRepresentation(Status status, Resource resource) { return toRepresentation(status, resource.getRequest(), resource.getResponse()); }
if (response.getStatus().isError() && ((response.getEntity() == null) || isOverwriting())) { response.setEntity(getStatusService().toRepresentation( response.getStatus(), request, response));
/** * 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); } }