- public static ResponseEntity<Object> create(String text, HttpStatus code) {
- ErrorInfo p = new ErrorInfo(text, code.value());
+ public static ResponseEntity<Object> create(Exception e, HttpStatus code) {
+ if (e instanceof RuntimeException) {
+ code = HttpStatus.INTERNAL_SERVER_ERROR;
+ }
+ ErrorInfo p = new ErrorInfo(e.toString(), code.value());