|
20 | 20 | public class ApplicationErrorController implements ErrorController { |
21 | 21 |
|
22 | 22 | @ExceptionHandler |
23 | | - @RequestMapping(path="", method={ GET, POST, PUT, HEAD, PATCH, DELETE, OPTIONS, TRACE }) |
| 23 | + @RequestMapping(path="", method={ GET, POST, PUT, HEAD, PATCH, DELETE, OPTIONS, TRACE }) |
24 | 24 | public String handleError( |
25 | 25 | HttpServletRequest request |
26 | 26 | ) { |
27 | | - log.info("handleError"); |
28 | 27 | String errorMessage = (String) request.getAttribute(ERROR_MESSAGE); |
29 | 28 | if(errorMessage!=null){ |
30 | | - log.warn("errorMessage :"+errorMessage); |
| 29 | + errorMessage = errorMessage.strip(); |
| 30 | + log.warn("handleError - errorMessage: "+errorMessage); |
31 | 31 | } |
32 | 32 | Integer statusCode = (Integer) request.getAttribute(ERROR_STATUS_CODE); |
33 | 33 | if(statusCode != null){ |
34 | 34 | HttpStatus httpStatus = HttpStatus.valueOf(statusCode); |
35 | | - log.warn(httpStatus.value()+""+httpStatus.getReasonPhrase()); |
| 35 | + log.warn(httpStatus.value()+" "+httpStatus.getReasonPhrase()); |
| 36 | + String redirectLoginPageWithError = "redirect:/user/login?login_error=1"; |
36 | 37 | switch (httpStatus){ |
37 | 38 | case NOT_FOUND: |
38 | 39 | log.warn("##################################################"); |
39 | | - log.warn(" 404 NOT_FOUND"); |
| 40 | + log.warn("# 404 NOT_FOUND #"); |
40 | 41 | log.warn("##################################################"); |
41 | 42 | return "error/error-404"; |
42 | 43 | case INTERNAL_SERVER_ERROR: |
43 | 44 | log.warn("##################################################"); |
44 | | - log.warn(" 500 INTERNAL_SERVER_ERROR"); |
| 45 | + log.warn("# 500 INTERNAL_SERVER_ERROR #"); |
45 | 46 | log.warn("##################################################"); |
46 | 47 | return "error/error-500"; |
47 | 48 | case UNAUTHORIZED: |
48 | 49 | log.warn("##################################################"); |
49 | | - log.warn(" 401 UNAUTHORIZED"); |
| 50 | + log.warn("# 401 UNAUTHORIZED #"); |
50 | 51 | log.warn("##################################################"); |
51 | | - return "redirect:/user/login?login_error=1"; |
| 52 | + return redirectLoginPageWithError; |
52 | 53 | case METHOD_NOT_ALLOWED: |
53 | 54 | log.warn("##################################################"); |
54 | | - log.warn(" 405 METHOD_NOT_ALLOWED"); |
| 55 | + log.warn("# 405 METHOD_NOT_ALLOWED #"); |
55 | 56 | log.warn("##################################################"); |
56 | | - return "redirect:/user/login?login_error=1"; |
| 57 | + return redirectLoginPageWithError; |
57 | 58 | case FORBIDDEN: |
58 | 59 | log.warn("##################################################"); |
59 | | - log.warn(" 403 FORBIDDEN"); |
| 60 | + log.warn("# 403 FORBIDDEN #"); |
60 | 61 | log.warn("##################################################"); |
61 | | - return "redirect:/user/login?login_error=1"; |
| 62 | + return redirectLoginPageWithError; |
62 | 63 | case REQUEST_TIMEOUT: |
63 | 64 | log.warn("##################################################"); |
64 | | - log.warn(" 408 REQUEST_TIMEOUT"); |
| 65 | + log.warn("# 408 REQUEST_TIMEOUT #"); |
65 | 66 | log.warn("##################################################"); |
66 | | - return "redirect:/user/login?login_error=1"; |
| 67 | + return redirectLoginPageWithError; |
67 | 68 | case CONFLICT: |
68 | 69 | log.warn("##################################################"); |
69 | | - log.warn(" 409 CONFLICT"); |
| 70 | + log.warn("# 409 CONFLICT #"); |
70 | 71 | log.warn("##################################################"); |
71 | | - return "redirect:/user/login?login_error=1"; |
| 72 | + return redirectLoginPageWithError; |
72 | 73 | case PRECONDITION_FAILED: |
73 | 74 | log.warn("##################################################"); |
74 | | - log.warn(" 412 PRECONDITION_FAILED"); |
| 75 | + log.warn("# 412 PRECONDITION_FAILED #"); |
75 | 76 | log.warn("##################################################"); |
76 | | - return "redirect:/user/login?login_error=1"; |
| 77 | + return redirectLoginPageWithError; |
77 | 78 | case URI_TOO_LONG: |
78 | 79 | log.warn("##################################################"); |
79 | | - log.warn(" 414 URI_TOO_LONG"); |
| 80 | + log.warn("# 414 URI_TOO_LONG #"); |
80 | 81 | log.warn("##################################################"); |
81 | | - return "redirect:/user/login?login_error=1"; |
| 82 | + return redirectLoginPageWithError; |
82 | 83 | case UNSUPPORTED_MEDIA_TYPE: |
83 | 84 | log.warn("##################################################"); |
84 | | - log.warn(" 415 UNSUPPORTED_MEDIA_TYPE"); |
| 85 | + log.warn("# 415 UNSUPPORTED_MEDIA_TYPE #"); |
85 | 86 | log.warn("##################################################"); |
86 | | - return "redirect:/user/login?login_error=1"; |
| 87 | + return redirectLoginPageWithError; |
87 | 88 | } |
88 | 89 | } |
89 | 90 | Throwable exception = (Throwable) request.getAttribute(ERROR_EXCEPTION); |
|
0 commit comments