List of usage examples for org.springframework.web.util WebUtils ERROR_MESSAGE_ATTRIBUTE
String ERROR_MESSAGE_ATTRIBUTE
To view the source code for org.springframework.web.util WebUtils ERROR_MESSAGE_ATTRIBUTE.
Click Source Link
From source file:org.carewebframework.ui.ExceptionController.java
/** * Populate the display with information from the current execution. * //www. j av a 2 s .c o m * @see org.zkoss.zk.ui.util.GenericAutowireComposer#doAfterCompose(org.zkoss.zk.ui.Component) */ @Override public void doAfterCompose(final Component comp) throws Exception { super.doAfterCompose(comp); Clients.clearBusy(); this.root = ZKUtil.findAncestor(comp, Window.class); final HttpServletRequest req = (HttpServletRequest) this.execution.getNativeRequest(); Class<?> errClass = (Class<?>) req.getAttribute(WebUtils.ERROR_EXCEPTION_TYPE_ATTRIBUTE); String errMsg = (String) req.getAttribute(WebUtils.ERROR_MESSAGE_ATTRIBUTE); Throwable err = (Throwable) req.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE); final String errReqURI = (String) req.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE); final String errServletName = (String) req.getAttribute(WebUtils.ERROR_SERVLET_NAME_ATTRIBUTE); final Integer errStatusCode = (Integer) req.getAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE); String throwableContext = null; if (err != null) { if (err instanceof IThrowableContext) { throwableContext = ((IThrowableContext) err).getThrowableContext(); } //stack trace info if (err instanceof NestedCheckedException) { err = ((NestedCheckedException) err).getMostSpecificCause(); } else if (err instanceof NestedRuntimeException) { err = ((NestedRuntimeException) err).getMostSpecificCause(); } } if (err != null) { errClass = errClass == null ? err.getClass() : errClass; errMsg = StringUtils.trimToNull(errMsg) == null ? err.getMessage() : errMsg; } final StringBuffer buffer = new StringBuffer(); //generic exception info buffer.append("\nException class: ").append(errClass); buffer.append("\nMessage: ").append(errMsg); if (err instanceof ErrorCoded) { final String errorCode = ((ErrorCoded) err).getErrorCode(); buffer.append("\nErrorCode: ").append(errorCode); this.lblCode.setValue(errorCode); } buffer.append("\nStatusCode: ").append(errStatusCode); buffer.append("\nServletName: ").append(errServletName); buffer.append("\nReqURI: ").append(errReqURI); final SessionInfo sessionInfo = Application.getInstance().getSessionInfo(this.desktop); buffer.append(sessionInfo); buffer.append("\nThrowableContext: " + throwableContext); buffer.append("\nStackTrace: "); appendStackTrace(err); log.error(buffer, err); this.lblExceptionClass.setValue(String.valueOf(errClass)); this.lblMessage.setValue(errMsg); this.lblStatusCode.setValue(String.valueOf(errStatusCode)); if (SecurityUtil.isGrantedAny(Labels.getLabel("cwf.error.dialog.expanded"))) { Events.echoEvent(Events.ON_CLICK, this.btnDetail, null); } }
From source file:com.wiiyaya.consumer.web.main.controller.ExceptionController.java
@RequestMapping(MainURIResource.PATH_ERROR_ALL) public String error(HttpServletRequest request) throws Throwable { Integer code = (Integer) request.getAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE); Throwable exception = (Throwable) request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE); String simpleMsg = (String) request.getAttribute(WebUtils.ERROR_MESSAGE_ATTRIBUTE); if (exception != null) { throw getRootCause(exception); } else {/*from ww w . jav a2s .com*/ switch (code) { case 404: throw new PageNotFoundException(); case 403: throw new AccessDeniedException(simpleMsg); default: throw new Exception(simpleMsg); } } }
From source file:com.devnexus.ting.web.controller.SiteController.java
@RequestMapping("/s/handleGlobaleErrors") public String onUploadError(HttpServletRequest request, final Model model, RedirectAttributes redirectAttributes) { final Object errorExceptionObject = request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE); if (errorExceptionObject instanceof MultipartException) { final MultipartException multipartException = (MultipartException) errorExceptionObject; final Throwable rootCause = multipartException.getRootCause(); String errorMessage = ""; if (rootCause instanceof SizeLimitExceededException || rootCause instanceof FileSizeLimitExceededException) { errorMessage = String.format( "The file that you are trying to upload is unfortunately too big. Uploaded files cannot be bigger than <strong>%s</strong>." + " Please go back and upload a smaller image file.", multipartProperties.getMaxFileSize()); } else {/*from w w w .j av a 2s .c om*/ errorMessage = (String) request.getAttribute(WebUtils.ERROR_MESSAGE_ATTRIBUTE); } redirectAttributes.addFlashAttribute("error", errorMessage); return "redirect:/s/uploadError"; } else { return "error/error"; } }
From source file:com.wiiyaya.consumer.web.main.controller.ExceptionController.java
/** * /*from www .j a v a 2s .c om*/ * @param request ? * @param exception * @return ExceptionDto JSON */ @ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ModelAndView springErrorHand(HttpServletRequest request, Exception exception) { String simpleMsg = (String) request.getAttribute(WebUtils.ERROR_MESSAGE_ATTRIBUTE); String errorCode = exception == null ? simpleMsg : exception.getClass().getSimpleName(); String errorMessage = exception == null ? simpleMsg : exception.getMessage(); LOGGER.error("Error catch: statusCode[{}], errorMessage[{}], errorUrl[{}]", HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMessage, request.getRequestURI(), exception); return prepareExceptionInfo(request, HttpStatus.INTERNAL_SERVER_ERROR, errorCode, errorMessage); }