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.
Prerequisites: Run ./mvnw validate or mvn validate before applying any changes. If validation fails, stop immediately — do not proceed until the project is in a valid state. Also confirm the VAVR dependency (io.vavr:vavr) and SLF4J are present when introducing Either types.
Core areas: Optional for nullable values over throwing NullPointerException or NotFoundException, VAVR Either for predictable business-logic failures, CompletableFuture 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 with flatMap/map/peek/peekLeft for chaining operations th...
Java에서 기능적 예외 처리 모범 사례를 적용해야 하는 경우 사용합니다. 여기에는 예외 남용을 Optional 및 VAVR 양쪽 유형으로 대체, 봉인된 클래스 및 열거형을 사용하여 오류 유형 계층 구조 설계, 모나드 오류 구성 파이프라인 구현, 기능적 제어 흐름 패턴 설정, 실제로 예외적인 시스템 수준 오류에 대해서만 예외 예약 등이 포함됩니다. Skills-for-Java 프로젝트의 일부 출처: jabrena/cursor-rules-java.