perf(CreateUserController): añadido control de excepción para valores únicos

parent c995361b
...@@ -31,8 +31,12 @@ public class CreateUserController { ...@@ -31,8 +31,12 @@ public class CreateUserController {
.collect(Collectors.joining("; ")); .collect(Collectors.joining("; "));
throw new UnprocessableEntityException(errorMsg); throw new UnprocessableEntityException(errorMsg);
} }
URI location = URI.create("/user"); try {
return ResponseEntity.created(location).body(service.create(userInputDto)); URI location = URI.create("/user");
return ResponseEntity.created(location).body(service.create(userInputDto));
} catch (Exception e) {
throw new UnprocessableEntityException("Usuario ya registrado. Cambie sus credenciales.");
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment