From 536273c2fc01b1a9f1e2b6fc7e04fef28053e985 Mon Sep 17 00:00:00 2001 From: PedroVidalDev Date: Mon, 15 Apr 2024 18:47:17 -0300 Subject: [PATCH] [feat] - change the text plain response to json --- .../java/com/pedro/sphynx/application/dtos/error/Error.java | 4 ++++ .../sphynx/infrastructure/exceptions/ErrorExceptions.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/pedro/sphynx/application/dtos/error/Error.java diff --git a/src/main/java/com/pedro/sphynx/application/dtos/error/Error.java b/src/main/java/com/pedro/sphynx/application/dtos/error/Error.java new file mode 100644 index 0000000..53c8ae2 --- /dev/null +++ b/src/main/java/com/pedro/sphynx/application/dtos/error/Error.java @@ -0,0 +1,4 @@ +package com.pedro.sphynx.application.dtos.error; + +public record Error(String message) { +} diff --git a/src/main/java/com/pedro/sphynx/infrastructure/exceptions/ErrorExceptions.java b/src/main/java/com/pedro/sphynx/infrastructure/exceptions/ErrorExceptions.java index 341096d..a146d44 100644 --- a/src/main/java/com/pedro/sphynx/infrastructure/exceptions/ErrorExceptions.java +++ b/src/main/java/com/pedro/sphynx/infrastructure/exceptions/ErrorExceptions.java @@ -21,6 +21,6 @@ public ResponseEntity noSuchElement(){ @ExceptionHandler(Validation.class) public ResponseEntity validation(Validation e){ - return ResponseEntity.badRequest().body(e.getMessage()); + return ResponseEntity.badRequest().body(new Error(e.getMessage())); } }