Class ExceptionMappingRegistry

java.lang.Object
io.leandev.appfuse.error.ExceptionMappingRegistry

public class ExceptionMappingRegistry extends Object

異常映射器註冊中心

管理所有 ExceptionMapper 並按優先順序匹配, 將異常轉換為 RFC 7807 ProblemDetail。

  • Constructor Details

    • ExceptionMappingRegistry

      public ExceptionMappingRegistry()
      使用預設的 Mapper 集合初始化
  • Method Details

    • register

      public void register(ExceptionMapper<?> mapper)
      註冊自定義 Mapper
      Parameters:
      mapper - 異常映射器
    • map

      public org.springframework.http.ProblemDetail map(Exception exception)
      將異常映射為 ProblemDetail (RFC 7807)
      Parameters:
      exception - 異常
      Returns:
      ProblemDetail