Skip to content

Commit c894502

Browse files
committed
change some status codes in HTTP response
1 parent d42fc9b commit c894502

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/com/bezkoder/spring/datajpa/controller/TutorialController.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public ResponseEntity<Tutorial> createTutorial(@RequestBody Tutorial tutorial) {
6767
.save(new Tutorial(tutorial.getTitle(), tutorial.getDescription(), false));
6868
return new ResponseEntity<>(_tutorial, HttpStatus.CREATED);
6969
} catch (Exception e) {
70-
return new ResponseEntity<>(null, HttpStatus.EXPECTATION_FAILED);
70+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
7171
}
7272
}
7373

@@ -92,7 +92,7 @@ public ResponseEntity<HttpStatus> deleteTutorial(@PathVariable("id") long id) {
9292
tutorialRepository.deleteById(id);
9393
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
9494
} catch (Exception e) {
95-
return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
95+
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
9696
}
9797
}
9898

@@ -102,7 +102,7 @@ public ResponseEntity<HttpStatus> deleteAllTutorials() {
102102
tutorialRepository.deleteAll();
103103
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
104104
} catch (Exception e) {
105-
return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
105+
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
106106
}
107107

108108
}
@@ -117,7 +117,7 @@ public ResponseEntity<List<Tutorial>> findByPublished() {
117117
}
118118
return new ResponseEntity<>(tutorials, HttpStatus.OK);
119119
} catch (Exception e) {
120-
return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
120+
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
121121
}
122122
}
123123

0 commit comments

Comments
 (0)