Errorping is a Spring Boot–oriented error handling library that provides a unified, extensible way to handle exceptions, generate API error responses, control logging behavior, and optionally trigger alerts.
It is designed to be used as a library, while allowing application-level customization through simple interface implementations.
- Spring Boot 3.5.4
- JDK 17
- Servlet-based stack (
spring-boot-starter-web)
- Centralized global exception handling for Spring Boot
- Pluggable ExceptionResolver architecture
- Consistent API error response format
- Per-exception log level control
- Custom log message formatting
- Optional alert triggering per exception
- No controller-level boilerplate
In the errorping project:
./gradlew publishToMavenLocalThen, in your application:
dependencies {
implementation "com.jhssong:errorping:0.0.0-SNAPSHOT"
}Check most recent version at here
repositories {
maven {
url = uri("https://maven.pkg.github.com/jhssong/errorping")
credentials {
username = project.findProperty("gpr.user")
password = project.findProperty("gpr.key")
}
}
}
dependencies {
implementation "com.jhssong:errorping:0.2.0"
}GitHub Packages requires authentication even for public repositories.
ExceptionResolver
public interface ExceptionResolver {
boolean support(Throwable ex);
ErrorResponse resolve(Throwable ex, HttpServletRequest request);
LogLevel logLevel();
String logMessage(ErrorResponse er, HttpServletRequest request);
default boolean shouldAlert(Throwable ex) {
return false;
}
}Each resolver is responsible for:
- Determining whether it supports a given exception
- Creating a standardized ErrorResponse
- Defining log level and log message
- Optionally triggering alerts
ErrorResponse
{
"timestamp": "2026-01-08T17:30:43.257027",
"status": "BAD_REQUEST",
"title": "잘못된 요청입니다.",
"message": "부적절한 이름입니다."
}In your project, simply implement the interface:
@Component
public class CustomExceptionResolver implements ExceptionResolver {
@Override
public boolean support(Throwable ex) {
return ex instanceof CustomException;
}
@Override
public ErrorResponse resolve(Throwable ex, HttpServletRequest httpServletRequest) {
CustomException e = (CustomException) ex;
return ErrorResponse.builder()
.status(e.getStatus())
.title(e.getTitle())
.message(e.getMessage())
.build();
}
@Override
public LogLevel logLevel() {
return LogLevel.ERROR;
}
@Override
public String logMessage(ErrorResponse er, HttpServletRequest request) {
return String.format("[CustomException] status=%s method=%s uri=%s message=%s",
er.getStatus(),
request.getMethod(),
request.getRequestURI(),
er.getMessage());
}
@Override
public boolean shouldAlert(Throwable ex) {
CustomException e = (CustomException) ex;
return e.isShouldAlert();
}
}- Automatically detected by Errorping’s global exception handler
- No additional configuration required
Errorping uses Spring Boot @ConfigurationProperties to load alert-related settings.
To enable Discord alerting, add the following to your application.yml:
errorping:
discord-webhook-url: ${DISCORD_WEBHOOK_URL}Discord alerts are sent only when both conditions are met:
- The corresponding
ExceptionResolverreturnstruefromshouldAlert(Throwable ex) errorping.discord-webhook-urlis configured
This allows full control over which exceptions should trigger external alerts.
- An exception is thrown in a controller
- ErrorPing’s GlobalExceptionHandler intercepts it
- All registered ExceptionResolvers are scanned (ordered)
- The first resolver that support()s the exception is used
- Error response is returned
- Log is written using the resolver’s log level & message
- Alert is triggered if shouldAlert() is true
If multiple resolvers support the same exception, they are evaluated in order using Spring's
@OrderorOrderedinterface.
For more examples, check errorping-example
