main
Last change
on this file since e15e8d9 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
|
Line | |
---|
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;
|
---|
5 | import org.springframework.http.HttpStatus;
|
---|
6 | import org.springframework.http.ResponseEntity;
|
---|
7 | import org.springframework.http.converter.HttpMessageNotWritableException;
|
---|
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 | }
|
---|
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 | }
|
---|
25 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.