Interface ErrorDisclosurePolicy
- All Known Implementing Classes:
MaximalErrorDisclosurePolicy, MinimalErrorDisclosurePolicy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
決定完整錯誤診斷如何投影成 HTTP response 的最後一道政策接點。
框架在進入本接點前同時保留詳細與最小兩種 ProblemDetail,不在 exception mapper、
authentication entry point 或 controller 中提前丟棄資訊。框架預設使用
MaximalErrorDisclosurePolicy;應用可改注入 MinimalErrorDisclosurePolicy,或實作自己的
欄位級揭露政策。
-
Method Summary
-
Method Details
-
disclose
org.springframework.http.ProblemDetail disclose(org.springframework.http.ProblemDetail detailed, org.springframework.http.ProblemDetail minimal, Throwable cause) 選擇並補充最終對外錯誤。- Parameters:
detailed- 完整技術錯誤投影minimal- 最小穩定錯誤投影cause- 原始例外;沒有例外的拒絕情境可為 null- Returns:
最終寫入 HTTP response 的 ProblemDetail
實作可直接改寫傳入的
detailed或minimal;因此 exception mapper 與呼叫端必須為每個 request 建立新的ProblemDetail,不可回傳或重用共用實例。框架內建的最大揭露政策另會先 複製detailed,避免第三方 mapper 意外共享物件時造成跨 request 汙染。
-