spring - How to handle multiple exceptions in @exeptionhandler and response body? -
should create method org.springframework.security.access.accessdeniedexception parameter?
@controlleradvice public class accessdeniedexceptionadvice { private final logger log = loggerfactory.getlogger(getclass()); @autowired private errorresponsemapperservice errorresponsemapper; @exceptionhandler({ com.mycomp.myapp.platform.common.exception.accessdeniedexception.class , org.springframework.security.access.accessdeniedexception.class }) // <-- here have added exeption @responsestatus(value = httpstatus.forbidden) @responsebody public errorresponsedto accessdenied(com.mycomp.myapp.platform.common.exception.accessdeniedexception.class ex) { log.error("access denied", ex); return errorresponsemapper.createerrorreponsedto(null, "access denied", myapperrorcodesenumdto.my_app_unauthorized_exception); } }
Comments
Post a Comment