for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* User: alec
* Date: 28.12.18
* Time: 15:21
*/
namespace AlecRabbit\Traits;
trait DoesProcessException
{
/** @var bool */
protected $throwOnError = true;
/** @return self */
public function doNotThrowOnError(): self
$this->throwOnError = false;
return $this;
}
public function throwOnError(): self
$this->throwOnError = true;
/** @return bool */
public function doesThrowsOnError(): bool
return $this->throwOnError;
* @param \Throwable $e
* @throws \Throwable
protected function processException(\Throwable $e): void
if ($this->throwOnError) {
throw $e;
if (\defined('APP_DEBUG') && APP_DEBUG) {
$hasDumpFunction = \function_exists('dump');
if (\defined('DEBUG_DUMP_EXCEPTION') && DEBUG_DUMP_EXCEPTION) {
$exceptionMessage = '[' . \get_class($e) . '] ' . $e->getMessage();
if ($hasDumpFunction) {
dump($exceptionMessage, $e->getTraceAsString());
} else {
// @codeCoverageIgnoreStart
var_dump($exceptionMessage, $e->getTraceAsString());
var_dump($exceptionMessa...$e->getTraceAsString())
// @codeCoverageIgnoreEnd
if (\defined('DEBUG_DUMP_EXCEPTION_CLASS') && DEBUG_DUMP_EXCEPTION_CLASS) {
dump($e);
var_dump($e);