laravel:exception-handling-and-logging

Use reportable/renderable exceptions, structured logs, and channel strategy for observability and graceful failures

jpcaparas/superpowers-laravel118 installsMITSynced Aug 26

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: laravel:exception-handling-and-logging
description: Use reportable/renderable exceptions, structured logs, and channel strategy for observability and graceful failures
license: MIT
---

# 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()`

More Observability skills

← All Observability skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY