Resolve the appropriate Exception Handler

@param \Exception $exception

@return \App\Exceptions\Handler
14086
public function resolve(Exception $exception)
	{
		if($abettor = $this->getAbettor($exception))
		{
			return new $abettor;
		}

		return $this->handler;
	}
741744
public function handleException(\Exception $exception)
    {
        $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']);

        if ($isAjax) {

            $sEngine = Response\Factory::ENGINE_API;
            $sFormat = Response\Factory::FORMAT_JSON;
            $content = json_encode($exception->getTraceAsString());
        } else {
            $sEngine = Response\Factory::ENGINE_TEMPLATE;
            $sFormat = Response\Factory::FORMAT_HTML;

            if (EKA_ENV !== 'prod') {
                $contentHtml = '<b>Exception[' . $exception->getCode() . ']: ' . $exception->getMessage() . '</b><pre>' . $exception->getTraceAsString() . '</pre>';
            }

            $layoutPath = Config::getInstance()->get('Eureka\Global\Theme\php\layout');
            $themeName  = Config::getInstance()->get('Eureka\Global\Theme\php\theme');
            $content    = new Template($layoutPath . '/Template/' . $themeName . '/Main');
            $content->setVar('content', $contentHtml);
            $content->setVar('meta', Config::getInstance()->get('meta'));
        }

        $response = Response\Factory::create($sFormat, $sEngine);
        $response->setHttpCode(500)->setContent($content)->send();
    }
519175
public function handle(Exception $e)
    {
        foreach ($this->handlers as $handler) {
            if ($handler->manages($e)) {
                return $handler->handle($e);
            }
        }

        throw new RuntimeException('Exception handler for '.get_class($e).' not found.');
    }
557364
public function exceptionHandler($exception)
    {
        $context = array(
            'file'    => $exception->getFile(),
            'line'    => $exception->getLine()
        );

        if ($this->reportBacktrace) {
            $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace($exception);
        }

        if ($this->exceptionInContext) {
            $context['exception'] = $exception;
        }

        $this->logger->error(
            $message = 'Uncaught ' . get_class($exception) . ': ' . $exception->getMessage(),
            $context
        );

        // Exceptions must be reported in general because they stop the regular display of the page
        if ($this->showErrors || $this->getEnvReporter()->isLive()) {
            $this->getErrorReporter()->reportError($exception);
        }
    }
1343335
private function handleError($exception)
    {
        if ($this->errorCallback !== null) {
            $callback = $this->errorCallback;
            $callback($exception);
        }
    }
584665
public function exceptionHandler($exception) {
		try {
			// load errorhandler
			$debug = Factory::load('Debug');
			$debug->errorhandler($exception);
		} catch (\Exception $e) {
			echo "<pre>$exception</pre>\n\n";

			// useful if the \Exception handler itself contains errors
			echo "<pre>The Debug class threw an exception:\n$e</pre>";
		}
	}
1254212
public static function handleException(\Exception $exception) {
        $context = [];
        $second  = null;

        try {
            $context['class'    ] = __CLASS__;
            $context['file'     ] = $exception->getFile();  // If the location is not preset the logger will resolve the
            $context['line'     ] = $exception->getLine();  // exception handler as the originating location.
            $context['unhandled'] = true;

            Logger::log($exception, L_FATAL, $context);     // log with the highest level
        }

        // Exceptions thrown from within the exception handler will not be passed back to the handler again. Instead the
        // script terminates with an uncatchable fatal error.
        catch (\Exception $second) {
            $indent = ' ';                                  // the application is crashing, last try to log

            // secondary exception
            $msg2  = '[FATAL] Unhandled '.trim(DebugHelper::composeBetterMessage($second)).NL;
            $file  = $second->getFile();
            $line  = $second->getLine();
            $msg2 .= $indent.'in '.$file.' on line '.$line.NL.NL;
            $msg2 .= $indent.'Stacktrace:'.NL.$indent.'-----------'.NL;
            $msg2 .= DebugHelper::getBetterTraceAsString($second, $indent);

            // primary (the causing) exception
            if (isset($context['cliMessage'])) {
                $msg1 = $context['cliMessage'];
                if (isset($context['cliExtra']))
                    $msg1 .= $context['cliExtra'];
            }
            else {
                $msg1  = $indent.'Unhandled '.trim(DebugHelper::composeBetterMessage($exception)).NL;
                $file  = $exception->getFile();
                $line  = $exception->getLine();
                $msg1 .= $indent.'in '.$file.' on line '.$line.NL.NL;
                $msg1 .= $indent.'Stacktrace:'.NL.$indent.'-----------'.NL;
                $msg1 .= DebugHelper::getBetterTraceAsString($exception, $indent);
            }

            $msg  = $msg2.NL;
            $msg .= $indent.'caused by'.NL;
            $msg .= $msg1;
            $msg  = str_replace(chr(0), '?', $msg);         // replace NUL bytes which mess up the logfile

            if (CLI)                                        // full second exception
                echo $msg.NL;
            error_log(trim($msg), ERROR_LOG_DEFAULT);
        }

        // web: prevent an empty page
        if (!CLI) {
            try {
                if (Application::isAdminIP() || ini_get_bool('display_errors')) {
                    if ($second) {                          // full second exception, full log location
                        echoPre($second);
                        echoPre('error log: '.(strlen($errorLog=ini_get('error_log')) ? $errorLog : 'web server'));
                    }
                }
                else echoPre('application error (see error log)');
            }
            catch (\Exception $third) {
                echoPre('application error (see error log)');
            }
        }
    }
448188
public function handleException($exception)
    {
        $this->setExceptionHandler(null);
        $this->setErrorHandler(null);
        
        $isInstanceOf = array_map(function ($class) use ($exception) {
            return is_a($exception, $class);
        }, $this->logExceptionClasses);
        
        if ($exception instanceof \Error || $exception instanceof \ErrorException) {
            $type = $exception instanceof \Error ? $exception->getCode() : $exception->getSeverity();
            $shouldLog = $this->getLoggedErrorTypes() & $type;
        } else {
            $shouldLog = array_sum($isInstanceOf) > 0;
        }
        
        if ($shouldLog) {
            $this->log($exception);
        }
        
        $this->callOnFatalError($exception);
        
        if ($this->chainedExceptionHandler) {
            call_user_func($this->chainedExceptionHandler, $exception);
        }
        
        throw $exception; // This is now handled by the default exception and error handler
    }
198014
public static function exception(\Exception $exception)
    {
        if (!$exception instanceof RestException) {
            $exception = RestException::createFromException($exception);
        }

        return RestResponse::create(['errors' => $exception->errors()], $exception->getCode());
    }
179575
public function handle($exception)
    {
        $handlers = (array)$this->config('handlers');
        foreach ($handlers as $handler => $config) {
            $handlerClass = $handler;
            if (!class_exists($handlerClass)) {
                $handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
            }
            if (!class_exists($handlerClass)) {
                $handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler . 'Handler';
            }
            if (!class_exists($handlerClass)) {
                continue;
            }
            $instance = new $handlerClass((array)$config);
            $instance->handle($exception);
        }

        return false;
    }
205066
public function handleException($exception)
    {
        // Walk the registered handlers in the reverse order
        // they were registered, and pass off the exception
        $inspector = $this->getInspector($exception);

        // Capture output produced while handling the exception,
        // we might want to send it straight away to the client,
        // or return it silently.
        $this->system->startOutputBuffering();

        // Just in case there are no handlers:
        $handlerResponse = null;
        $handlerContentType = null;

        foreach (array_reverse($this->handlerStack) as $handler) {
            $handler->setRun($this);
            $handler->setInspector($inspector);
            $handler->setException($exception);

            // The HandlerInterface does not require an Exception passed to handle()
            // and neither of our bundled handlers use it.
            // However, 3rd party handlers may have already relied on this parameter,
            // and removing it would be possibly breaking for users.
            $handlerResponse = $handler->handle($exception);

            // Collect the content type for possible sending in the headers.
            $handlerContentType = method_exists($handler, 'contentType') ? $handler->contentType() : null;

            if (in_array($handlerResponse, [Handler::LAST_HANDLER, Handler::QUIT])) {
                // The Handler has handled the exception in some way, and
                // wishes to quit execution (Handler::QUIT), or skip any
                // other handlers (Handler::LAST_HANDLER). If $this->allowQuit
                // is false, Handler::QUIT behaves like Handler::LAST_HANDLER
                break;
            }
        }

        $willQuit = $handlerResponse == Handler::QUIT && $this->allowQuit();

        $output = $this->system->cleanOutputBuffer();

        // If we're allowed to, send output generated by handlers directly
        // to the output, otherwise, and if the script doesn't quit, return
        // it so that it may be used by the caller
        if ($this->writeToOutput()) {
            // @todo Might be able to clean this up a bit better
            if ($willQuit) {
                // Cleanup all other output buffers before sending our output:
                while ($this->system->getOutputBufferLevel() > 0) {
                    $this->system->endOutputBuffering();
                }

                // Send any headers if needed:
                if (Misc::canSendHeaders() && $handlerContentType) {
                    header("Content-Type: {$handlerContentType}");
                }
            }

            $this->writeToOutputNow($output);
        }

        if ($willQuit) {
            // HHVM fix for https://github.com/facebook/hhvm/issues/4055
            $this->system->flushOutputBuffer();

            $this->system->stopExecution(1);
        }

        return $output;
    }
589842
protected function getCode(\Exception $exception)
    {
        return $exception instanceof \ErrorException ?
            $this->getHumanErrorCode($exception->getSeverity()) :
            $exception->getCode()
        ;
    }
820874
public function getExceptionHandler() : ExceptionHandlerInterface
    {
        if (!$this->exceptionHandler) {
            $this->exceptionHandler = new ExceptionHandler(
                (bool) $this->getConfiguration('displayErrors')
            );
        }

        return $this->exceptionHandler;
    }
807687
public function handleException(Exception $exception)
    {
        $this->_sendFatalError("Fatal proxy Exception: '"
                               . $exception->getMessage()
                               . "' in "
                               . $exception->getFile()
                               . ":"
                               . $exception->getLine());
    }
404789
protected function handleException($handler, Throwable $exception)
	{
		if($handler instanceof Closure)
		{
			return $handler($exception);
		}

		return $this->handlerFactory($handler)->handle($exception);
	}
31983
public function exceptionHandler($exception)
    {
        $this->lastHandledException = $exception;

        $this->client->catchException($exception);

        if ($this->oldExceptionHandler) {
            call_user_func(
                $this->oldExceptionHandler,
                $exception
            );
        }
    }
841603
private function getErrorHandler(Throwable $exception): ?ErrorHandlerInterface
    {
        $errorHandler = null;

        // search from the end of the array because we need to take the last added handler (LIFO style)
        foreach (array_reverse($this->handlers) as $exceptionType => $handler) {
            if (\is_a($exception, $exceptionType)) {
                $errorHandler = $handler;

                break;
            }
        }

        return $errorHandler;
    }