Class HttpMessageConversionExceptionMapper

java.lang.Object
io.leandev.appfuse.error.mapper.HttpMessageConversionExceptionMapper
All Implemented Interfaces:
ExceptionMapper<org.springframework.http.converter.HttpMessageConversionException>

public class HttpMessageConversionExceptionMapper extends Object implements ExceptionMapper<org.springframework.http.converter.HttpMessageConversionException>

HTTP 訊息轉換異常映射器

處理 JSON 解析錯誤等,轉換為 RFC 7807 ProblemDetail。

  • Constructor Details

    • HttpMessageConversionExceptionMapper

      public HttpMessageConversionExceptionMapper()
  • Method Details

    • supports

      public boolean supports(Exception exception)
      Description copied from interface: ExceptionMapper
      檢查此 Mapper 是否支援給定的異常
      Specified by:
      supports in interface ExceptionMapper<org.springframework.http.converter.HttpMessageConversionException>
      Parameters:
      exception - 待檢查的異常
      Returns:
      true 如果支援,否則 false
    • map

      public org.springframework.http.ProblemDetail map(org.springframework.http.converter.HttpMessageConversionException ex)
      Description copied from interface: ExceptionMapper
      將異常轉換為 ProblemDetail (RFC 7807)
      Specified by:
      map in interface ExceptionMapper<org.springframework.http.converter.HttpMessageConversionException>
      Parameters:
      ex - 待轉換的異常
      Returns:
      ProblemDetail 錯誤回應物件