Exception handling and logging
Skill jpcaparas/superpowers-laravel/skills/exception-handling-and-logging
Use reportable/renderable exceptions, structured logs, and channel strategy for observability and graceful failuresFrom its SKILL.md
npx -y skills add jpcaparas/superpowers-laravel --skill exception-handling-and-loggingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
0.9 KB, as published. Nobody here has run it
Exception Handling and Logging
Treat errors as first-class signals; provide context and paths to remediation.
Commands
// app/Exceptions/Handler.php
public function register(): void
{
$this->reportable(function (DomainException $e) {
Log::warning('domain exception', ['code' => $e->getCode()]);
});
$this->renderable(function (ModelNotFoundException $e, $request) {
if ($request->expectsJson()) {
return response()->json(['message' => 'Not Found'], 404);
}
});
}
Patterns
- Use domain-specific exceptions for expected error paths
- Add structured context to logs; avoid logging secrets
- Route noisy logs to separate channels; keep defaults actionable
- Convert to API-appropriate responses in
renderable()