mcpField
L
laravel:exception-handling-and-logging

laravel:exception-handling-and-logging

github.com/jpcaparasDevelopment157142 installsUpdated 18w ago
Repository

About laravel:exception-handling-and-logging

A Laravel development skill for handling exceptions and logs with actionable context. It covers domain-specific exceptions, structured logging, separate channels for noisy logs, and API-appropriate error responses.

Key features

  1. 01Define domain-specific exceptions
  2. 02Add structured context to logs
  3. 03Avoid logging secrets
  4. 04Separate noisy log channels
  5. 05Render API-appropriate responses

Use cases

  1. 01Logging expected domain errors
  2. 02Returning API responses for missing models

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel:exception-handling-and-logging

After installing, type/laravel:exception-handling-and-loggingin Claude Code to confirm it loaded.

Details

From the project README

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

Comments

Markdown supported