fix(booking): 交易內只攔截業務例外,資料庫錯誤改交由例外處理器 #75

Merged
a620906209 merged 2 commits from fix/booking-exception-handling-impl into master 2026-10-17 17:38:44 +00:00
Owner

摘要

M7:預約交易的錯誤分類。對應 OpenSpec change fix-booking-exception-handling(規劃 PR #74)。

  • 新增 App\Exceptions\BookingRuleViolationException
  • MemberBookingController::store、ProviderBookingController::confirm 只 catch 業務例外並回 422,訊息文字不變
  • QueryException 等其他例外不再以 422 回傳 SQL,改由 Laravel 回 500({"message":"Server Error"})並回報 Sentry

Commits

  • ddbf956 fix:功能變更與測試
  • 8042f0b style:只用 pint 格式化兩個 Controller,沒有邏輯變更(審查 B-001)

測試

  • 新增 tests/Feature/BookingExceptionHandlingTest.php,5 個測試對應 spec 的 5 個 Scenario
  • cfdive-test-gd 容器跑完整 php artisan test:257 passed(675 assertions)
  • 變異驗證:把 catch 改回 \RuntimeException 後,兩個 500 測試會失敗
  • pint:本次變更的 4 個檔案全部通過
  • 審查:Claude strict-reviewer PASS;Pi 交叉審查 PASS

安全確認

  • 輸入驗證:沿用 $request->validate(),不變
  • 權限:沿用 member/provider middleware 與 authorizeProvider(),不變
  • N+1:沒有新增查詢
  • 鎖:沿用 CourseSchedule 的 lockForUpdate,不變

限制

  • 測試使用 SQLite,驗證不了 MySQL 的真實行鎖、死結與逾時,只能確認例外分類與 rollback
  • 500 body 不洩漏細節的前提是 APP_DEBUG=false(VPS 已確認,H2)

部署後

  • tasks 3.2:在正式環境建立一筆預約、確認一筆預約(201/200)
  • 合併後另開 PR 歸檔(/opsx:archive)

🤖 Generated with Claude Code

## 摘要 M7:預約交易的錯誤分類。對應 OpenSpec change `fix-booking-exception-handling`(規劃 PR #74)。 - 新增 `App\Exceptions\BookingRuleViolationException` - `MemberBookingController::store`、`ProviderBookingController::confirm` 只 catch 業務例外並回 422,訊息文字不變 - `QueryException` 等其他例外不再以 422 回傳 SQL,改由 Laravel 回 500(`{"message":"Server Error"}`)並回報 Sentry ## Commits - `ddbf956` fix:功能變更與測試 - `8042f0b` style:只用 pint 格式化兩個 Controller,沒有邏輯變更(審查 B-001) ## 測試 - 新增 `tests/Feature/BookingExceptionHandlingTest.php`,5 個測試對應 spec 的 5 個 Scenario - `cfdive-test-gd` 容器跑完整 `php artisan test`:257 passed(675 assertions) - 變異驗證:把 catch 改回 `\RuntimeException` 後,兩個 500 測試會失敗 - pint:本次變更的 4 個檔案全部通過 - 審查:Claude strict-reviewer PASS;Pi 交叉審查 PASS ## 安全確認 - 輸入驗證:沿用 `$request->validate()`,不變 - 權限:沿用 `member`/`provider` middleware 與 `authorizeProvider()`,不變 - N+1:沒有新增查詢 - 鎖:沿用 `CourseSchedule` 的 `lockForUpdate`,不變 ## 限制 - 測試使用 SQLite,驗證不了 MySQL 的真實行鎖、死結與逾時,只能確認例外分類與 rollback - 500 body 不洩漏細節的前提是 `APP_DEBUG=false`(VPS 已確認,H2) ## 部署後 - [ ] tasks 3.2:在正式環境建立一筆預約、確認一筆預約(201/200) - 合併後另開 PR 歸檔(`/opsx:archive`) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
a620906209 added 2 commits 2026-10-17 17:37:52 +00:00
新增 BookingRuleViolationException,MemberBookingController::store 與
ProviderBookingController::confirm 只 catch 此型別並回 422(訊息不變)。
QueryException 等其他例外不再被當成 422 回傳 SQL,改由 Laravel 回 500
並回報 Sentry。對應 OpenSpec change fix-booking-exception-handling(M7)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
style(booking): 以 pint 格式化預約 Controller
Run Tests / test (pull_request) Successful in 34s
8042f0bafb
純格式化,不含邏輯變更。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a620906209 merged commit a869b0989a into master 2026-10-17 17:38:44 +00:00
a620906209 deleted branch fix/booking-exception-handling-impl 2026-10-17 17:38:45 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: a620906209/CFDivePlatform#75