# Standardize Java Error Handling

Backend teams often create inconsistent exceptions, response bodies, and logging behavior across services. This skill gives Claude, Codex, and Claude Code a concrete Allra pattern for Java error handling.

## Install

```bash
npx skillstore add allra-fintech/allra-error-handling
```

## Metadata

- - Slug: allra-fintech-allra-error-handling
- - Version: 1.0.0
- - Author: Allra-Fintech
- - GitHub username: Allra-Fintech
- - License: MIT
- - Repository: https://github.com/Allra-Fintech/allra-ai-skills/tree/main/backend-plugin/skills/error-handling
- - Ref: main
- - Supported tools: Claude, Codex, Claude Code
- - Risk level: medium
- - Quality score: 73
- - Public page: https://skillstore.pages.dev/skills/allra-fintech-allra-error-handling
- - Manifest: https://skillstore.pages.dev/api/skills/allra-fintech-allra-error-handling/manifest

## Capabilities

- Defines a BusinessException hierarchy for Java services.
- Shows ErrorCode enum patterns with HTTP status codes.
- Guides Spring Boot global exception handler implementation.
- Specifies a standard error response shape.
- Demonstrates service-layer exception use with repositories.
- Provides logging level guidance for business and system errors.

## Use Cases

- Create Consistent Service Exceptions: Generate custom exception classes that follow the Allra BusinessException and ErrorCode pattern.
- Implement Global API Error Handling: Build a Spring Boot controller advice that maps business, validation, and unexpected exceptions to standard responses.
- Review Error Handling Standards: Check service-layer code for consistent exception throwing, response formats, and logging levels.

## Prompt Templates

### Create a Basic Exception

```
Create a Java custom exception for a missing order using the Allra error handling standard.
```

### Add Error Codes

```
Extend the ErrorCode enum for payment failure, duplicate account, and forbidden account access.
```

### Implement Controller Advice

```
Implement a Spring Boot global exception handler that follows the Allra standard and avoids leaking sensitive values.
```

### Audit an Error Flow

```
Review this service and controller error flow against the Allra standard. Identify inconsistent exceptions, response shapes, and logging risks.
```

## Limitations

- It is guidance documentation, not a runnable library.
- It focuses on Java and Spring Boot style backends.
- It does not validate code against a live Allra repository.
- Some logging examples need privacy review before production use.

## Best Practices

- Use one shared error code catalog for each service boundary.
- Redact personal data, tokens, passwords, and rejected secrets in logs and responses.
- Handle expected business exceptions separately from unexpected system exceptions.

## Anti Patterns

- Do not return stack traces or internal exception details to API clients.
- Do not log raw user input, credentials, tokens, or full personal identifiers.
- Do not create unrelated response formats for each controller.

## Security Audit

- - Safe to publish: true
- - Audited at: 2026-06-28T09:29:25.941\+00:00
- - Summary: The static external command findings are false positives caused by markdown code fences in SKILL.md, not executable shell or Ruby code. The weak cryptography and reconnaissance alerts are also false positives from normal prose or Java examples. A moderate issue remains because examples show rejected values and email addresses in responses or logs, which can expose personal data if copied directly.

## Stats

- - Views: 153
- - Downloads: 8
- - Favorites: 0
- - Popularity score: 0
