Skip to content

Commit

Permalink
Centralize Error Handling/Mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
tscz committed Aug 18, 2019
1 parent 621077c commit 4c2b8f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/jalp/server/CustomErrorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zalando.problem.Problem;
import org.zalando.problem.ThrowableProblem;
import org.zalando.problem.spring.web.advice.AdviceTrait;
import org.zalando.problem.spring.web.advice.ProblemHandling;
import org.zalando.problem.spring.web.advice.security.SecurityAdviceTrait;

/**
* Overrides default error controller from spring, because Exceptions thrown in
* {@link javax.servlet.Filter} are not handled in
* {@link org.springframework.web.bind.annotation.ExceptionHandler}.
*/
@RestController
public class CustomErrorController implements ErrorController, AdviceTrait {
@ControllerAdvice
public class CustomErrorController implements ErrorController, AdviceTrait, ProblemHandling, SecurityAdviceTrait {

@RequestMapping(value = "/error")
Problem error(HttpServletRequest request, HttpServletResponse response) throws Throwable {
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/jalp/server/ExceptionHandler.java

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/java/com/jalp/server/SecurityExceptionHandler.java

This file was deleted.

0 comments on commit 4c2b8f9

Please sign in to comment.