/** * Returns a status for a given exception or error. By default it returns an * {@link Status#SERVER_ERROR_INTERNAL} status and logs a severe message.<br> * In order to customize the default behavior, this method can be * overridden. * * @param throwable * The exception or error caught. * @param resource * The parent resource. * @return The representation of the given status. * @deprecated Use {@link #toStatus(Throwable, Resource)} instead. */ @Deprecated public Status getStatus(Throwable throwable, Resource resource) { return toStatus(throwable, (resource == null) ? null : resource.getRequest(), (resource == null) ? null : resource.getResponse()); }
super.doHandle(request, response); } catch (Throwable throwable) { Status status = getStatusService().toStatus(throwable, 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); } }