Search in sources :

Example 1 with ErrorPageRegistrar

use of org.springframework.boot.web.server.ErrorPageRegistrar in project scoold by Erudika.

the class ScooldServer method errorPageRegistrar.

/**
 * @return Error page registry bean
 */
@Bean
public ErrorPageRegistrar errorPageRegistrar() {
    return new ErrorPageRegistrar() {

        @Override
        public void registerErrorPages(ErrorPageRegistry epr) {
            epr.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/not-found"));
            epr.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, "/error/403"));
            epr.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, "/error/401"));
            epr.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500"));
            epr.addErrorPages(new ErrorPage(HttpStatus.SERVICE_UNAVAILABLE, "/error/503"));
            epr.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400"));
            epr.addErrorPages(new ErrorPage(HttpStatus.METHOD_NOT_ALLOWED, "/error/405"));
            epr.addErrorPages(new ErrorPage(Exception.class, "/error/500"));
        }
    };
}
Also used : ErrorPageRegistry(org.springframework.boot.web.server.ErrorPageRegistry) ErrorPage(org.springframework.boot.web.server.ErrorPage) ErrorPageRegistrar(org.springframework.boot.web.server.ErrorPageRegistrar) Bean(org.springframework.context.annotation.Bean)

Aggregations

ErrorPage (org.springframework.boot.web.server.ErrorPage)1 ErrorPageRegistrar (org.springframework.boot.web.server.ErrorPageRegistrar)1 ErrorPageRegistry (org.springframework.boot.web.server.ErrorPageRegistry)1 Bean (org.springframework.context.annotation.Bean)1