Last active
August 29, 2015 14:23
-
-
Save iandmyhand/5eac372fb2c6d1f6054d to your computer and use it in GitHub Desktop.
Handle error for RereadableRequestWrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping("/error") | |
@Controller | |
public class ErrorController { | |
@RequestMapping("/pageNotFound") | |
@ResponseBody | |
public Response pageNotFound() { | |
return new ErrorResponse(ErrorCode.NOT_FOUND_API.getCode(), ErrorCode.NOT_FOUND_API.getMessage()); | |
} | |
@RequestMapping("/servletException") | |
@ResponseBody | |
public Response defaultServletExceptionResponse(HttpServletRequest request, HttpServletResponse response) { | |
ErrorResponse errorResponse = null; | |
try { | |
errorResponse = (ErrorResponse)request.getAttribute("errorResponse"); | |
} catch (Exception e) { | |
} | |
if (errorResponse != null) { | |
return errorResponse; | |
} else { | |
return new ErrorResponse(ErrorCode.UNKNOWN.getCode(), ErrorCode.UNKNOWN.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment