--- kind: CONCEPT slug: adapter-outbound-persistence-jpa-c03 title: 위험한 shape 자체를 표현하기 어렵게 만든다 topic: state-machines-and-ownership project: clean-architecture-backend-template status: 게시 전 sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 rootTreeNode: concept:adapter-outbound-persistence-jpa-c03 evidenceCapturedOn: 2026-09-01 assets: - key: adapter-outbound-persistence-jpa-c03 file: ../../../final/evidence/rendered/adapter-outbound-persistence-jpa-c03.svg evidence: - ../../../final/evidence/raw/adapter-outbound-persistence-jpa-c03.txt source: - 원본 분석 절은 analysis/05-adapter-outbound-persistence-jpa.md#L208 이다. module: adapter-outbound-persistence-jpa --- # 위험한 shape 자체를 표현하기 어렵게 만든다 error hierarchy의 핵심은 예외 class를 많이 만든 것이 아니라 provider-specific signal을 bounded semantic category로 변환하는 것이다. ## 본문 error hierarchy의 핵심은 "예외 class를 많이 만든 것"이 아니라 provider-specific signal을 bounded semantic category로 변환하는 것이다. 대표 category는 serialization failure, deadlock, optimistic conflict, lock not available, connection unavailable, timeout 계열, unique/FK/not-null/check constraint, entity not found, schema mismatch, data corruption, completion unknown이다. 이 category는 뒤의 retry policy/metric이 SQLSTATE/provider message를 직접 해석하지 않게 하는 중간 vocabulary다. ## JpaFailureContext 참조 위치 :::evidence key="adapter-outbound-persistence-jpa-c03" alt="코드베이스에서 JpaFailureContext 를 검색한 출력 31줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="JpaFailureContext 코드베이스 검색 — 31줄 · exit 0" zoom="true" ::: ## 표현 자체를 막는 네 불변식 `JpaFailureContext`가 가지는 정보는 operation, SQLSTATE/constraint, attempt, retryability, completion-unknown, elapsed, trace 등으로 제한된다. - arbitrary identifier는 그대로 담지 않고 bounded/redacted form으로 축약 - malformed SQLSTATE는 `redacted`, absent SQLSTATE는 sentinel로 표현 - completion unknown과 retryable=true를 동시에 표현할 수 없음 - completion-unknown factory는 항상 automatic retry를 차단하는 형태를 만든다 즉 "exception이 발생한 뒤 로그에서 실수하지 말자"보다 앞선 위치에서 **failure context가 위험한 shape 자체를 표현하기 어렵게** 만든다. ## 메시지가 provider cause를 복사하지 않는다 base exception message는 provider cause message를 그대로 복사하지 않고 category + bounded context로 만든다. dedicated test도 provider cause에 email marker를 넣었을 때 top-level exception message에 노출되지 않는 것을 검증한다. 동시에 raw `Throwable cause`는 보존한다.