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())); } }