Skip to content

Commit

Permalink
add helpers: capture_exception_and_abort
Browse files Browse the repository at this point in the history
  • Loading branch information
uyab committed Jan 11, 2020
1 parent c3e8b0e commit 55e6a6c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,22 @@ function capture_exception(Throwable $exception)
}
}
}

if (! function_exists('capture_exception_and_abort')) {
/**
* Capture and report exception
*
* @param Throwable $exception
*
* @return string
* @throws Throwable
*/
function capture_exception_and_abort(Throwable $exception)
{
capture_exception($exception);
if (config('app.debug')) {
throw $exception;
}
abort($exception->getCode(), $exception->getMessage());
}
}

0 comments on commit 55e6a6c

Please sign in to comment.