|
|
|
@ -21,7 +21,6 @@ import java.util.Map; |
|
|
|
|
* resources: |
|
|
|
|
* add-mappings: false |
|
|
|
|
* 只有如此, springboot 才会触发异常。 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -31,15 +30,15 @@ public class ErrorController { |
|
|
|
|
@ExceptionHandler(Exception.class) |
|
|
|
|
@ResponseBody |
|
|
|
|
public ResponseEntity error(Exception ex) { |
|
|
|
|
System.out.println("ErrorController.error Exception"); |
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
System.out.println("ErrorController.error Exception"); |
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("Exception", ex.getClass().getName()); |
|
|
|
|
map.put("message", ex.getMessage()); |
|
|
|
|
map.put("localizedMessage", ex.getLocalizedMessage()); |
|
|
|
|
map.put("toString", ex.toString()); |
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.failed(map, "发生异常 "+ex.getMessage())); |
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.failed(map, "发生异常 " + ex.getMessage())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|