0

How would i remove the lengthy stack trace errors that Laravel uses by default? (i understand it is using "Ignition")

Some resources that i've found that did not help:

  • this thread only mentions how to disable error reporting altogether
  • when i write anything in a render() method in the app/Exceptions/Handler.php like mentioned here i only get error 500 without any output.
  • person in this thread even suggests writing your own Laravel bootstrap application instead of using the default one, breaking Laravel framework semantics, but that's just plain mad.

I have also tried looking at configuration values for Ignition by publishing ignition config file via

php artisan vendor:publish --provider="Facade\Ignition\IgnitionServiceProvider" --tag="ignition-config"

But that file has nothing to configure, the only thing you can do is to hide the "share" message in the error.

I just want a simple classic php error page with file/line/error, no stack traces, or no html markup. The error page makes it really difficult to debug output in anything else than a web browser.

user151496
  • 1,849
  • 24
  • 38
  • What did you write in the `render()` method of your exception handler that caused an error? You can just remove the Ignition package, although it would then fall back to Whoops. – miken32 Jan 27 '22 at 18:03
  • And if you're returning HTML pages, yes they're typically difficult to debug outside a web browser. What are you doing that returns HTML outside the context of a web browser? – miken32 Jan 27 '22 at 18:05
  • it depends; either it's testing something via shell command, or debugging a raw request for Lighthouse via curl (https://lighthouse-php.com/master/digging-deeper/file-uploads.html#client-side-usage), or using a request simulation app like ARC/PostMan, a lot of cases really. actually i'm debugging more often in everything else but the classic web browser mostly, especially if you're writing backend – user151496 Jan 28 '22 at 13:36

1 Answers1

1

Simply override the render() method in your app's exception handler. Per comments in the base class, this method must return a response object.

public function render($request, \Throwable $e)
{
    return response()->view("exception", ["exception" => $e]);
}

Then make your blade view look however you want.

<!doctype html>
<title>Exception</title>
<body>
<p>
Exception of type <code>{{ get_class($exception) }}</code>
thrown in <code>{{ $exception->getFile() }}</code>
on line <code>{{ $exception->getLine() }}</code>.
</p>
</body>
miken32
  • 42,008
  • 16
  • 111
  • 154