fix: ApiResponse 4xx 에러에서 스택 트레이스 제외 및 Controller 메서드 수정
- 4xx 클라이언트 에러에는 스택 트레이스 제외 - 5xx 서버 에러에만 debug 모드에서 스택 트레이스 포함 - 10개 Controller의 ApiResponse::handle() → success() 수정 - BankAccountController, SiteController, CardController - DepositController, WithdrawalController, SaleController - PurchaseController, PayrollController, ReportController - WorkSettingController - import 경로 수정 (App\Http\Responses → App\Helpers)
This commit is contained in:
@@ -182,15 +182,20 @@ public static function handle(
|
||||
|
||||
// HttpException 계열은 상태코드/메시지를 그대로 반영
|
||||
if ($e instanceof HttpException) {
|
||||
$statusCode = $e->getStatusCode();
|
||||
// 4xx 클라이언트 에러에는 스택 트레이스 제외, 5xx 서버 에러에만 debug 모드에서 포함
|
||||
$includeTrace = $statusCode >= 500 && config('app.debug');
|
||||
|
||||
return self::error(
|
||||
$e->getMessage() ?: '서버 에러',
|
||||
$e->getStatusCode(),
|
||||
['details' => config('app.debug') ? $e->getTraceAsString() : null]
|
||||
$statusCode,
|
||||
['details' => $includeTrace ? $e->getTraceAsString() : null]
|
||||
);
|
||||
}
|
||||
|
||||
// 일반 예외는 500으로 처리, debug 모드에서만 스택 트레이스 포함
|
||||
return self::error('서버 에러', 500, [
|
||||
'details' => $e->getMessage(),
|
||||
'details' => config('app.debug') ? $e->getTraceAsString() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user