143-java-functional-exception-handling
Skill452 starsChanged 3 months agoApache-2.0View on GitHub
Use when you need to apply functional exception handling best practices in Java — including replacing exception overuse with Optional and VAVR Either types, designing error type hierarchies using sealed classes and enums, implementing monadic error composition pipelines, establishing functional control flow patterns, and reserving exceptions only for truly exceptional system-level failures. This should trigger for requests such as Improve the code with Functional Exception Handling; Apply Functional Exception Handling; Refactor the code with Functional Exception Handling; Model Java errors with Result or Either types; Replace exception-heavy flows with functional error handling. Part of Plinth Toolkit
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Before applying any functional exception handling changes, ensure the project validates.
- Very specific: line 31
MANDATORY: Run ./mvnw validate or mvn validate before applying any changes
- Distinctive: line 32
SAFETY: If validation fails, stop immediately — do not proceed until the project is in a valid state
- Very specific: line 33
DEPENDENCY: When introducing Either types, confirm VAVR (io.vavr:vavr) and SLF4J are present
- Very specific: line 34
VERIFY: Run ./mvnw clean verify or mvn clean verify after applying improvements
- Distinctive: line 35
BEFORE APPLYING: Read the reference for detailed good/bad examples, constraints, and safeguards for each functional exception handling …
- Very specific: line 49
Run ./mvnw validate or mvn validate and stop immediately if validation fails.
- Very specific: line 53
When introducing Either, confirm VAVR (io.vavr:vavr) and SLF4J are present before implementation.
- Very specific: line 57
Read references/143-java-functional-exception-handling.md and identify places to replace exception-heavy control flow with monadic error …
- Very specific: line 65
Run ./mvnw clean verify or mvn clean verify after applying improvements.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Java Functional Exception handling Best Practices
Identify and apply functional exception handling best practices in Java to improve error clarity, maintainability, and performance by eliminating exception overuse in favour of monadic error types.
What is covered in this Skill?
Optional<T>for nullable values over throwingNullPointerExceptionorNotFoundException- VAVR
Either<L,R>for predictable business-logic failures CompletableFuture<T>for async error handling- Sealed classes and records for rich error type hierarchies with exhaustive pattern matching
- Enum-based error types for simple failure cases
- Functional composition:
flatMap/map/peek/peekLeftfor chaining operations that can fail - Structured logging: warn/info for business failures, error for system failures
- Checked vs unchecked exception discipline
- Exception chaining with full causal context when exceptions are unavoidable
Scope: The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.
Constraints
Before applying any functional exception handling changes, ensure the project validates. When introducing Either types, confirm the VAVR dependency (io.vavr:vavr) and SLF4J are present.
- MANDATORY: Run
./mvnw validateormvn validatebefore applying any changes - SAFETY: If validation fails, stop immediately — do not proceed until the project is in a valid state
- DEPENDENCY: When introducing
Eithertypes, confirm VAVR (io.vavr:vavr) and SLF4J are present - VERIFY: Run
./mvnw clean verifyormvn clean verifyafter applying improvements - BEFORE APPLYING: Read the reference for detailed good/bad examples, constraints, and safeguards for each functional exception handling pattern
When to use this skill
- Improve the code with Functional Exception Handling
- Apply Functional Exception Handling
- Refactor the code with Functional Exception Handling
- Model Java errors with Result or Either types
- Replace exception-heavy flows with functional error handling
Workflow
- Validate project before functional-exception changes
Run ./mvnw validate or mvn validate and stop immediately if validation fails.
- Check required dependencies
When introducing Either, confirm VAVR (io.vavr:vavr) and SLF4J are present before implementation.
- Read functional-exception reference and identify targets
Read references/143-java-functional-exception-handling.md and identify places to replace exception-heavy control flow with monadic error types.
- Apply functional exception-handling refactorings
Implement selected Optional/Either/async error patterns with structured logging and clear error contracts.
- Verify with full build
Run ./mvnw clean verify or mvn clean verify after applying improvements.
Reference
For detailed guidance, examples, and constraints, see references/143-java-functional-exception-handling.md.
Other versions2 projects use a version of this.
Word for word · 1
- jabrena/plinth★ 448100% same
Edited · 1
- jabrena/cursor-rules-examples★ 289% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository124 other files it gives its agents.
- AGENTS.mdAGENTS.md
- 001-commands-inventorySkill
- 002-agents-inventorySkill
- 003-skills-inventorySkill
- 004-commands-installationSkill
- 005-agents-installationSkill
- 012-agile-epicSkill
- 013-agile-featureSkill
- 014-agile-user-storySkill
- 021-problem-framingSkill
- 022-root-cause-analysisSkill
- 023-assumption-analysisSkill
- 024-context-mappingSkill
- 025-quality-attribute-discoverySkill
- 030-architecture-adr-generalSkill
- 033-architecture-diagramsSkill
- 041-planning-plan-modeSkill
- 042-planning-openspecSkill
- 043-planning-github-issuesSkill
- 044-planning-jiraSkill
- 045-planning-azure-devopsSkill
- 051-design-two-steps-methodsSkill
- 052-design-hamburger-methodSkill
- 053-design-simple-rulesSkill
- 054-design-tddSkill
- 055-design-parallel-changeSkill
- 056-design-avoid-breaking-changesSkill
- 057-design-feature-togglesSkill
- 058-design-bddSkill
- 059-design-atddSkill
- 110-java-maven-best-practicesSkill
- 111-java-maven-dependenciesSkill
- 112-java-maven-pluginsSkill
- 113-java-maven-documentationSkill
- 114-java-maven-searchSkill
- 121-java-object-oriented-designSkill
- 122-java-type-designSkill
- 123-java-design-patternsSkill
- 124-java-secure-codingSkill
- 125-java-concurrencySkill
- 126-java-exception-handlingSkill
- 128-java-genericsSkill
- 130-java-testing-strategiesSkill
- 131-java-testing-unit-testingSkill
- 132-java-testing-integration-testingSkill
- 133-java-testing-acceptance-testsSkill
- 141-java-refactoring-with-modern-featuresSkill
- 142-java-functional-programmingSkill
- 144-java-data-oriented-programmingSkill
- 145-java-refactoring-high-performanceSkill
- 151-java-performance-jmeterSkill
- 152-java-performance-gatlingSkill
- 161-java-profiling-detectSkill
- 162-java-profiling-analyzeSkill
- 163-java-profiling-refactorSkill
- 164-java-profiling-verifySkill
- 170-java-documentationSkill
- 181-java-observability-loggingSkill
- 182-java-observability-metrics-micrometerSkill
- 183-java-observability-tracing-opentelemetrySkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

