fix: improve error handling in handleAction method with logging and user-friendly message
This commit is contained in:
parent
9cf3e2bb6b
commit
0126321a6e
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
|
||||
@ -21,7 +22,8 @@ protected function handleAction(callable $action, string $successMessage, string
|
||||
|
||||
return to_route($errorRoute ?? $redirectRoute, $parameters);
|
||||
} catch (\Exception $e) {
|
||||
Inertia::flash('toast', ['type' => 'error', 'message' => $e->getMessage()]);
|
||||
Log::error($e->getMessage(), ['exception' => $e]);
|
||||
Inertia::flash('toast', ['type' => 'error', 'message' => 'Terjadi kesalahan. Silakan coba lagi.']);
|
||||
|
||||
return to_route($errorRoute ?? $redirectRoute, $parameters);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user