skills/error-handling-backend-java/SKILL.md
Implement consistent Java Spring Boot error handling with global exception handlers, custom exceptions, and structured error responses. Use when: building @RestControllerAdvice, creating domain exceptions, mapping errors to HTTP status codes, or structured error logging with SLF4J.
npx skillsauth add congiuluc/my-awesome-copilot error-handling-backend-javaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
@RestControllerAdviceApiResponse error envelope@RestControllerAdvice exception handlerNotFoundException, ValidationException, ConflictExceptionApiResponse envelope with error details — never expose stack tracesRuntimeException
├── NotFoundException → 404
├── ValidationException → 400
├── ConflictException → 409
├── UnauthorizedException → 401
├── ForbiddenException → 403
└── BusinessRuleException → 422
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
@ExceptionHandler(NotFoundException.class)
public ResponseEntity<ApiResponse<Void>> handleNotFound(NotFoundException ex) {
log.warn("Resource not found: {}", ex.getMessage());
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(ApiResponse.error(ex.getMessage()));
}
@ExceptionHandler(ValidationException.class)
public ResponseEntity<ApiResponse<Void>> handleValidation(ValidationException ex) {
log.warn("Validation failed: {}", ex.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ApiResponse.error(ex.getMessage()));
}
@ExceptionHandler(Exception.class)
public ResponseEntity<ApiResponse<Void>> handleUnexpected(Exception ex) {
log.error("Unexpected error", ex);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(ApiResponse.error("An unexpected error occurred."));
}
}
public record ApiResponse<T>(boolean success, T data, String error) {
public static <T> ApiResponse<T> ok(T data) {
return new ApiResponse<>(true, data, null);
}
public static <T> ApiResponse<T> error(String message) {
return new ApiResponse<>(false, null, message);
}
}
@Retry(name = "externalService", fallbackMethod = "fallback")
@CircuitBreaker(name = "externalService")
public String callExternalService() {
return restClient.get().uri("/api/data").retrieve().body(String.class);
}
public String fallback(Exception ex) {
log.warn("Fallback triggered for external service: {}", ex.getMessage());
return "default";
}
error level for unexpected errorsRuntimeExceptionApiResponse envelope — never raw error bodiestools
Build VS Code extensions with TypeScript. Covers extension anatomy, activation events, commands, tree views, webview panels, language features, testing, and publishing. Use when: creating a new VS Code extension, adding commands/views/providers, building webview UIs, implementing language server features, testing extensions, or packaging for the marketplace.
development
Track implementations, features, bugs, and releases in a versioning document. Use when: adding a commit, completing a feature, fixing a bug, or preparing a release. Automatically updates CHANGELOG.md following Keep a Changelog format and Semantic Versioning.
development
Write frontend tests using Vitest and React Testing Library. Use when: testing React components, hooks, user interactions, form submissions, accessibility assertions, or mocking API services.
development
Write Angular frontend tests using Jasmine, Karma, and Angular TestBed. Use when: testing Angular components, services, pipes, directives, user interactions, form submissions, accessibility assertions, or mocking HTTP services.