Class DataAccessExceptionMapper

java.lang.Object
io.leandev.appfuse.error.mapper.DataAccessExceptionMapper
All Implemented Interfaces:
ExceptionMapper<org.springframework.dao.DataAccessException>

public class DataAccessExceptionMapper extends Object implements ExceptionMapper<org.springframework.dao.DataAccessException>

Spring Data 異常映射器

處理 JPA/JDBC 資料庫操作異常,轉換為 RFC 7807 ProblemDetail。

  • Constructor Details

    • DataAccessExceptionMapper

      public DataAccessExceptionMapper()
  • Method Details

    • supports

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

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