driver api setting 1

This commit is contained in:
Hamza-Ayed
2026-04-25 11:42:40 +03:00
parent fccd758e93
commit fe5fa1feff
6 changed files with 547 additions and 59 deletions

View File

@@ -24,27 +24,39 @@ return Application::configure(basePath: dirname(__DIR__))
]);
})
->withExceptions(function (Exceptions $exceptions) {
$exceptions->render(function (\Throwable $e) {
\Log::error('Unhandled Exception', [
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
]);
if (config('app.debug')) {
return response()->json([
'status' => 'failure',
'message' => 'DEBUG ERROR: ' . $e->getMessage(),
$exceptions->render(function (\Throwable $e, \Illuminate\Http\Request $request) {
if ($request->is('api/*')) {
\Log::error('API Exception: ' . get_class($e), [
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine()
], 500);
}
'line' => $e->getLine(),
]);
return response()->json([
'status' => 'failure',
'message' => 'Internal server error',
], 500);
$status = 500;
if ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface) {
$status = $e->getStatusCode();
} elseif ($e instanceof \Illuminate\Validation\ValidationException) {
return response()->json([
'status' => 'failure',
'message' => 'Validation error',
'errors' => $e->errors(),
], 422);
}
$response = [
'status' => 'failure',
'message' => $e->getMessage() ?: 'Internal server error',
];
if (config('app.debug')) {
$response['exception'] = get_class($e);
$response['file'] = $e->getFile();
$response['line'] = $e->getLine();
$response['trace'] = $e->getTrace();
}
return response()->json($response, $status);
}
});
})
->create()