Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jbenner-radham/a30682a40ff1cf27a103 to your computer and use it in GitHub Desktop.

Select an option

Save jbenner-radham/a30682a40ff1cf27a103 to your computer and use it in GitHub Desktop.
<?php
/**
* Render an exception into a JSON HTTP response.
*
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public static function renderJson(Exception $e)
{
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler);
return new \Illuminate\Http\Response(
$whoops->handleException($e),
$e->getStatusCode(),
$e->getHeaders()
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment