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. Part of cursor-rules-java project
82
77%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./skills/143-java-functional-exception-handling/SKILL.mdIdentify 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 throwing NullPointerException or NotFoundExceptionEither<L,R> for predictable business-logic failuresCompletableFuture<T> for async error handlingflatMap/map/peek/peekLeft for chaining operations that can failScope: The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.
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.
./mvnw validate or mvn validate before applying any changesEither types, confirm VAVR (io.vavr:vavr) and SLF4J are present./mvnw clean verify or mvn clean verify after applying improvementsRun ./mvnw validate or mvn validate and stop immediately if validation fails.
When introducing Either, confirm VAVR (io.vavr:vavr) and SLF4J are present before implementation.
Read references/143-java-functional-exception-handling.md and identify places to replace exception-heavy control flow with monadic error types.
Implement selected Optional/Either/async error patterns with structured logging and clear error contracts.
Run ./mvnw clean verify or mvn clean verify after applying improvements.
For detailed guidance, examples, and constraints, see references/143-java-functional-exception-handling.md.
762cb86
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.