Opinionated Spring Boot starter that handles some Spring and AWS common exceptions and returns them in standardize json format.
This starter requires Java 17 and is compatible up to and including Java 19.
It also requires a Spring Boot MVC web application.
Spring Boot | starter-errors | Kotlin |
---|---|---|
3.0 | 9.x | 1.7 |
2.7 | 8.x | 1.7 |
2.6 | 7.x | 1.6 |
2.5 | 5.x | 1.5 |
2.4 | 4.x | 1.4 |
Other combinations might work, but they're not supported.
For example with Gradle Kotlin DSL :
implementation("com.ekino.oss.spring:ekino-spring-boot-starter-errors:8.0.0")
NB : if you want to use snapshots you need to add the following configuration to your Gradle build script :
repositories {
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
}
Default configuration is production-ready.
Anyway, if you want your json to contain the full stacktrace you have to add the following configuration :
ekino:
errors:
display-full-stacktrace: true # false by default
We recommend you to enable stacktraces only for local or any other development environment.
{
"status": 400,
"code": "error.invalid",
"message": "Bad Request",
"description": "Validation failed",
"errors": [
{
"code": "error.missing.company",
"field": "company",
"message": "must not be null"
}
],
"globalErrors": [],
"service": "my-api : POST /api/customers",
"stacktrace": "",
"timestamp": "2019-12-12T16:11:27.262Z"
}
{
"status": 403,
"code": "error.disabled_account",
"message": "Forbidden",
"description": "User is disabled",
"errors": [],
"globalErrors": [],
"service": "my-api : POST /api/auth",
"stacktrace": "",
"timestamp": "2019-12-12T16:11:27.262Z"
}