Skip to content

kodgemisi/better-error-pages-spring-boot-starter

Repository files navigation

Better Error Pages

Introduction

Build status jitpack

This is a Spring Boot Starter project which provides Rails like error pages for Spring Boot applications for development environments.

Screenshot

For rest requests, any error is archived until a configurable timeout and the error page url is sent in rest request’s response headers.

Screenshot
Screenshot

Demo

Note that demo page is a Heroku app so it may be sleeping when you first open the page, it may take 1-2 min for server to wake up.

Quick Start

Just add the dependency to your maven/gradle of your Spring Boot application then it will autoconfigure itself and Better Error Pages will be available if your active profiles includes dev or development.

Adding the dependency to your project

<dependencies>
  <dependency>
    <groupId>com.github.kodgemisi</groupId>
    <artifactId>better-error-pages-spring-boot-starter</artifactId>
    <version>${better-error-pages-spring-boot-starter.version}</version>
  </dependency>
</dependencies>

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

See https://jitpack.io/#kodgemisi/better-error-pages-spring-boot-starter for Jitpack usage, dependency details, version info and Gradle usage.

Configuration

Better Error Pages;

  • sets server.error.include-stacktrace: always and server.error.include-exception: true automatically.

  • autoconfigures itself if active profile has dev or development however you can override this via better-error-pages.profiles property.

  • finds your @SpringBootApplication annotated class and use its package name as better-error-pages.package-name name however you can override this via better-error-pages.package-name property.

Tip
Note that package-name should be typically your own base package which is used throughout your own classes like com.yourcompany.
better-error-pages:
  package-name: <String> # A package name whose classes' source code will be parsed and displayed in error pages.
  profiles: <String or List of string> # Override default profiles to enable Better Error Pages. Default value: "dev, development"
Important
Setting better-error-pages.package-name property improves startup performance significantly but won’t affect runtime performance.
Warning

If you set better-error-pages.package-name property then your project must have one of following files:

  • application.yml

  • application-dev.yml

  • application.properties

  • application-dev.properties

Limitations

  • Won’t work for package names containing upper case characters.

  • Can’t show source code in multi module projects only if the project is run as packaged but other features will work.

    • When running multi module projects from an IDE everything just works.

License

© Copyright 2018 Kod Gemisi Ltd.

Mozilla Public License 2.0 (MPL-2.0)

MPL is a copyleft license that is easy to comply with. You must make the source code for any of your changes available under MPL, but you can combine the MPL software with proprietary code, as long as you keep the MPL code in separate files. Version 2.0 is, by default, compatible with LGPL and GPL version 2 or greater. You can distribute binaries under a proprietary license, as long as you make the source available under MPL.