Skip to content

Commit

Permalink
重写report优雅记录
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 10, 2021
1 parent 7ef9665 commit a303a60
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Module\Base;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Log;
use Throwable;

class Handler extends ExceptionHandler
Expand Down Expand Up @@ -57,4 +58,18 @@ public function render($request, Throwable $e)
}
return parent::render($request, $e);
}

/**
* 重写report优雅记录
* @param Throwable $e
* @throws Throwable
*/
public function report(Throwable $e)
{
if ($e instanceof ApiException) {
Log::error($e->getMessage(), ['exception' => ' at ' . $e->getFile() .':' . $e->getLine()]);
} else {
parent::report($e);
}
}
}

0 comments on commit a303a60

Please sign in to comment.