Class MaximalErrorDisclosurePolicy
java.lang.Object
io.leandev.appfuse.error.MaximalErrorDisclosurePolicy
- All Implemented Interfaces:
ErrorDisclosurePolicy
框架預設的最大揭露政策。
保留 mapper 建立的 HTTP 語意,並把原始例外型別、訊息與有界 stack trace 放進 response。
應用若不希望輸出技術診斷,應在組裝層改注入 MinimalErrorDisclosurePolicy 或自訂政策。
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
DEFAULT_MAX_STACK_TRACE_CHARS
public static final int DEFAULT_MAX_STACK_TRACE_CHARS- See Also:
-
-
Constructor Details
-
MaximalErrorDisclosurePolicy
public MaximalErrorDisclosurePolicy() -
MaximalErrorDisclosurePolicy
public MaximalErrorDisclosurePolicy(int maxStackTraceChars)
-
-
Method Details
-
disclose
public org.springframework.http.ProblemDetail disclose(org.springframework.http.ProblemDetail detailed, org.springframework.http.ProblemDetail minimal, Throwable cause) Description copied from interface:ErrorDisclosurePolicy選擇並補充最終對外錯誤。- Specified by:
disclosein interfaceErrorDisclosurePolicy- Parameters:
detailed- 完整技術錯誤投影minimal- 最小穩定錯誤投影cause- 原始例外;沒有例外的拒絕情境可為 null- Returns:
最終寫入 HTTP response 的 ProblemDetail
實作可直接改寫傳入的
detailed或minimal;因此 exception mapper 與呼叫端必須為每個 request 建立新的ProblemDetail,不可回傳或重用共用實例。框架內建的最大揭露政策另會先 複製detailed,避免第三方 mapper 意外共享物件時造成跨 request 汙染。
-