diff --git a/src/main/java/ru/soune/nocopy/controller/ApiController.java b/src/main/java/ru/soune/nocopy/controller/ApiController.java index beb3035..460ad8b 100644 --- a/src/main/java/ru/soune/nocopy/controller/ApiController.java +++ b/src/main/java/ru/soune/nocopy/controller/ApiController.java @@ -66,7 +66,13 @@ public class ApiController { throw e; } catch (Exception e) { log.error("Handler execution failed for msgId: {}", msgId, e); - throw new RuntimeException("Handler execution failed", e); + + BaseResponse errorResponse = new BaseResponse(msgId, + MessageCode.INVALID_JSON_BODY.getCode(), + MessageCode.INVALID_JSON_BODY.getDescription(), + new HashMap<>()); + + return ResponseEntity.ok().body(errorResponse); } } diff --git a/src/main/java/ru/soune/nocopy/dto/MessageCode.java b/src/main/java/ru/soune/nocopy/dto/MessageCode.java index 8bf6c19..e5fd6e4 100644 --- a/src/main/java/ru/soune/nocopy/dto/MessageCode.java +++ b/src/main/java/ru/soune/nocopy/dto/MessageCode.java @@ -4,6 +4,7 @@ public enum MessageCode { SUCCESS(0, "Operation successful"), REG_EMAIL_EXISTS(1, "Email already registered"), INVALID_FIELD(2, "Invalid field"), + INVALID_JSON_BODY(2, "Invalid fields in JSON object"), MSG_ID_NOT_FOUND(4, "Message id not found"), AUTH_EMAIL_NOT_FOUND(4, "Email not found"),