fix : Base Service 추가 및 다국어 설정, DepartmentService 서비스를 static에서 인스턴스로 변경
- 모든 서비스를 인스턴스구조로 변경예정 * 규모가 커질수록 → 인스턴스(=DI) 설계가 유리 * 작고 단순한 유틸/순수 함수만 스태틱으로 유지 * DI/모킹/테스트 쉬움 (서비스 교체·부분 테스트 가능) * 의존성 교체 쉬움 (Repo/캐시/로거…) * 상태·컨텍스트 주입 명확 (테넌트/유저/트랜잭션)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class ApiResponse
|
||||
{
|
||||
@@ -159,6 +160,16 @@ public static function handle(
|
||||
return self::success($data, $responseTitle.' 성공', $debug);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
// HttpException 계열은 상태코드/메시지를 그대로 반영
|
||||
if ($e instanceof HttpException) {
|
||||
return self::error(
|
||||
$e->getMessage() ?: ($responseTitle.' 실패'),
|
||||
$e->getStatusCode(),
|
||||
['details' => config('app.debug') ? $e->getTraceAsString() : null]
|
||||
);
|
||||
}
|
||||
|
||||
return self::error($responseTitle.' 실패', 500, [
|
||||
'details' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user