Example usage for org.springframework.boot.web.server ErrorPageRegistry addErrorPages

List of usage examples for org.springframework.boot.web.server ErrorPageRegistry addErrorPages

Introduction

In this page you can find the example usage for org.springframework.boot.web.server ErrorPageRegistry addErrorPages.

Prototype

void addErrorPages(ErrorPage... errorPages);

Source Link

Document

Adds error pages that will be used when handling exceptions.

Usage

From source file:com.erudika.scoold.ScooldServer.java

/**
 * @return Error page registry bean/*w  ww  .  ja  v a 2 s . c o  m*/
 */
@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"));
        }
    };
}