Skip to content

Repository files navigation

Errorping

About The Project

Errorping is a lightweight library for Spring Boot that sends detailed error logs via Discord webhooks in real-time.

Built With

  • Spring Boot 3.5.4
  • JDK 17
  • Servlet-based stack (spring-boot-starter-web)

Features

  • Discord Webhook Integration: Sends highly readable Embed messages including status codes, request URL, and exception class.
  • Ready-to-use Templates: Provides a pre-configured GlobalExceptionHandler and Logback configuration for immediate integration.
  • Easy Configuration: Enable Discord alerting simply via application.yml without any additional code modifications.

Installation

Option 1: Maven Local (Recommended for development)

In the errorping project:

./gradlew publishToMavenLocal

Then, in your application:

dependencies {
    implementation "com.jhssong:errorping:0.0.0-SNAPSHOT"
}

Option 2: GitHub Packages (Recommended for production)

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:1.0.0"
}

GitHub Packages requires authentication even for public repositories.

Configuration

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}

Alert Preview

Example

Inject ErrorpingService into your @RestControllerAdvice and call sendErrorToDiscord inside each exception handler:

@Slf4j
@RestControllerAdvice
@RequiredArgsConstructor
public class GlobalExceptionHandler {

    private final ErrorpingService errorpingService;

    @ExceptionHandler(MethodArgumentNotValidException.class)
    protected ResponseEntity<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e,
                                                                         HttpServletRequest request) {
        String message = e.getBindingResult().getAllErrors().get(0).getDefaultMessage();
        log.info("[400] Validation Failed: {}", message);
        errorpingService.sendErrorToDiscord(e, HttpStatus.BAD_REQUEST, request, message);
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
    }

    @ExceptionHandler(Exception.class)
    protected ResponseEntity<Void> handleException(Exception e, HttpServletRequest request) {
        log.error("[500] Internal Server Error", e);
        errorpingService.sendErrorToDiscord(e, HttpStatus.INTERNAL_SERVER_ERROR, request, e.getMessage());
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}

For a full GlobalExceptionHandler covering more exception types and additional usage patterns, check errorping-example.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages