Limit-Status im Upload-Flow anzeigen (Warnbanner + Sperrzustände).

Upload-Fehlercodes auswerten und freundliche Dialoge zeigen.
This commit is contained in:
Codex Agent
2025-11-01 19:50:17 +01:00
parent 2c14493604
commit 79b209de9a
55 changed files with 3348 additions and 462 deletions

View File

@@ -2,10 +2,10 @@
namespace App\Exceptions;
use App\Support\ApiError;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use Illuminate\Validation\ValidationException;
use Inertia\Inertia;
use Throwable;
class Handler extends ExceptionHandler
{
@@ -32,35 +32,46 @@ class Handler extends ExceptionHandler
public function render($request, Throwable $e)
{
\Illuminate\Support\Facades\Log::info('Handler render called', ['inertia' => $request->inertia(), 'exception' => get_class($e), 'url' => $request->url()]);
if ($request->expectsJson()) {
if ($e instanceof ValidationException) {
return ApiError::response(
'validation_failed',
'Validation failed',
'The given data was invalid.',
422,
['errors' => $e->errors()],
);
}
if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
\Illuminate\Support\Facades\Log::error('Route not found (404)', [
'url' => $request->url(),
'method' => $request->method(),
'referer' => $request->header('referer'),
'user_agent' => $request->header('user-agent')
]);
$status = $this->isHttpException($e)
? $this->toHttpException($e)->getStatusCode()
: 500;
$code = $status >= 500 ? 'server_error' : 'request_failed';
return ApiError::response(
$code,
$status >= 500 ? 'Unexpected error' : 'Request could not be completed',
$this->buildGenericMessage($status),
$status,
);
}
if ($request->inertia()) {
if ($e instanceof ValidationException) {
\Illuminate\Support\Facades\Log::info('ValidationException in Inertia', ['errors' => $e->errors(), 'url' => $request->url()]);
return response()->json([
'message' => 'The given data was invalid.',
'errors' => $e->errors(),
], 422)->header('X-Inertia-Error', 'true');
}
if ($e instanceof \Exception) {
\Illuminate\Support\Facades\Log::info('Exception in Inertia', ['message' => $e->getMessage(), 'url' => $request->url()]);
return response()->json([
'message' => 'Registrierung fehlgeschlagen.',
'errors' => ['general' => $e->getMessage()],
], 500)->header('X-Inertia-Error', 'true');
return back()->withErrors($e->errors())->withInput($request->all());
}
}
return parent::render($request, $e);
}
}
private function buildGenericMessage(int $status): string
{
if ($status >= 500) {
return 'Something went wrong on our side. Please try again later.';
}
return 'Your request could not be processed. Please verify the details and try again.';
}
}