Added error checking for post calls

This commit is contained in:
grata
2023-04-27 16:12:49 +02:00
parent 33c2f8bf8a
commit 9b6cfc4fe2
9 changed files with 84 additions and 4 deletions

View File

@@ -60,6 +60,9 @@ public class UserController {
@PostMapping("")
public ResponseEntity<UserEntity> createUser(@RequestBody UserEntity user) {
UserEntity createdUser = userService.createUser(user);
if(createdUser == null) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<>(createdUser, HttpStatus.CREATED);
}