main
Last change
on this file was deea3c4, checked in by Aleksandar Panovski <apano77@…>, 3 weeks ago |
Big change done fully handle_reservation_update() trigger works
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[5a9c93b] | 1 | package com.example.rezevirajmasa.demo.config;
|
---|
| 2 |
|
---|
| 3 | import com.example.rezevirajmasa.demo.dto.ErrorDto;
|
---|
| 4 | import com.example.rezevirajmasa.demo.model.exceptions.AppException;
|
---|
[deea3c4] | 5 | import org.springframework.http.HttpStatus;
|
---|
[5a9c93b] | 6 | import org.springframework.http.ResponseEntity;
|
---|
[deea3c4] | 7 | import org.springframework.http.converter.HttpMessageNotWritableException;
|
---|
[5a9c93b] | 8 | import org.springframework.web.bind.annotation.ControllerAdvice;
|
---|
| 9 | import org.springframework.web.bind.annotation.ExceptionHandler;
|
---|
| 10 | import org.springframework.web.bind.annotation.ResponseBody;
|
---|
| 11 |
|
---|
| 12 | @ControllerAdvice
|
---|
| 13 | public class RestExceptionHandler {
|
---|
| 14 | @ExceptionHandler(value = {AppException.class})
|
---|
| 15 | @ResponseBody
|
---|
| 16 | public ResponseEntity<ErrorDto> handleException(AppException ex) {
|
---|
| 17 | return ResponseEntity.status(ex.getCode())
|
---|
| 18 | .body(ErrorDto.builder().message(ex.getMessage()).build());
|
---|
| 19 | }
|
---|
[deea3c4] | 20 |
|
---|
| 21 | @ExceptionHandler(HttpMessageNotWritableException.class)
|
---|
| 22 | public ResponseEntity<String> handleHttpMessageNotWritableException(HttpMessageNotWritableException ex) {
|
---|
| 23 | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the response.");
|
---|
| 24 | }
|
---|
[5a9c93b] | 25 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.