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

@@ -48,6 +48,9 @@ public class LocationController {
@PostMapping("")
public ResponseEntity<LocationEntity> createLocation(@RequestBody LocationEntity location) {
LocationEntity createdLocation = locationService.createLocation(location);
if(createdLocation == null) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<>(createdLocation, HttpStatus.CREATED);
}