use of com.enonic.xp.web.HttpStatus in project xp by enonic.
the class ExceptionRendererImpl method render.
@Override
public PortalResponse render(final WebRequest webRequest, final WebException cause) {
String tip = null;
final ExceptionInfo info = toErrorInfo(cause);
logIfNeeded(info);
if (webRequest instanceof PortalRequest) {
PortalRequest portalRequest = (PortalRequest) webRequest;
final HttpStatus httpStatus = cause.getStatus();
if (httpStatus != null) {
final String handlerMethod = "handle" + httpStatus.value();
final PortalResponse statusCustomError = renderCustomError(portalRequest, cause, handlerMethod);
if (statusCustomError != null) {
logIfNeeded(toErrorInfo(cause));
return statusCustomError;
}
}
final PortalResponse idProviderError = renderIdProviderError(portalRequest, cause);
if (idProviderError != null) {
logIfNeeded(toErrorInfo(cause));
return idProviderError;
}
final PortalResponse defaultCustomError = renderCustomError(portalRequest, cause, DEFAULT_HANDLER);
if (defaultCustomError != null) {
logIfNeeded(toErrorInfo(cause));
return defaultCustomError;
}
if ("/site".equals(portalRequest.getBaseUri()) && ContentConstants.BRANCH_MASTER.equals(portalRequest.getBranch()) && HttpStatus.NOT_FOUND.equals(cause.getStatus())) {
tip = "Tip: Did you remember to publish the site?";
}
}
return renderInternalErrorPage(webRequest, tip, cause);
}
use of com.enonic.xp.web.HttpStatus in project xp by enonic.
the class ExceptionMapperImpl method throwIfNeeded.
@Override
public void throwIfNeeded(final WebResponse res) throws WebException {
final HttpStatus status = res.getStatus();
final Object body = res.getBody();
if (isError(status) && (body == null)) {
throw new WebException(status, status.getReasonPhrase());
}
}
Aggregations