main
Last change
on this file since 5a9c93b was 5a9c93b, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Authorization layer
|
-
Property mode
set to
100644
|
File size:
739 bytes
|
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.ResponseEntity;
|
---|
6 | import org.springframework.web.bind.annotation.ControllerAdvice;
|
---|
7 | import org.springframework.web.bind.annotation.ExceptionHandler;
|
---|
8 | import org.springframework.web.bind.annotation.ResponseBody;
|
---|
9 |
|
---|
10 | @ControllerAdvice
|
---|
11 | public class RestExceptionHandler {
|
---|
12 | @ExceptionHandler(value = {AppException.class})
|
---|
13 | @ResponseBody
|
---|
14 | public ResponseEntity<ErrorDto> handleException(AppException ex) {
|
---|
15 | return ResponseEntity.status(ex.getCode())
|
---|
16 | .body(ErrorDto.builder().message(ex.getMessage()).build());
|
---|
17 | }
|
---|
18 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.