Construct a default exception resolver.

@return \Closure
493350
protected function defaultExceptionResolver(): Closure
    {
        return function (string $errorMessage) {
            return (new GenericException($errorMessage))
                ->setExtensions([$this->errorType => $this->errors])
                ->setCategory($this->errorType);
        };
    }
1067943
private function getResolver()
    {
        if ($this->resolver === null) {
            $this->resolver = new OptionsResolver();
            $this->configureOptions($this->resolver);
        }

        return $this->resolver;
    }
427114
public static function resolve(){

        $aArgs = func_get_args();

        $aDebug = debug_backtrace(1);

        if(isset($aDebug[1])){

            $oDebug = $aDebug[1];

            $function = $oDebug['function'];
            $class = $oDebug['class'];

            if(!empty($aArgs)){
                $args = $aArgs;
            } else {
                $args = $oDebug['args'];
            }

            $app = $class::getFacadeApplication();

            return call_user_func_array( array($app[$class::getFacadeAccessor()], $function), $args);
        } else {
            Throw new \Exception('Cannot resolve this function');
        }
    }
506024
public static function exception_handler(\Exception $e)
	{
		if (method_exists($e, 'handle'))
		{
			return $e->handle();
		}

		$severity = ( ! isset(static::$levels[$e->getCode()])) ? $e->getCode() : static::$levels[$e->getCode()];
		logger(\Fuel::L_ERROR, $severity.' - '.$e->getMessage().' in '.$e->getFile().' on line '.$e->getLine());

		if (\Fuel::$env != \Fuel::PRODUCTION)
		{
			static::show_php_error($e);
		}
		else
		{
			static::show_production_error($e);
		}
	}
205301
protected function defineExceptionHandler()
    {
        $exceptionRender = $this->obtainExceptionRender();
        
        //If not render to use
        if ($exceptionRender === false) {
            return;
        }
        
        //add the handler for exceptions
        set_exception_handler([$this, 'exceptionHandler']);
        
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug('New exception handler defined.')
        ;
    }
858517
static function Loader()
    {
        if (!self::$default_resolver) {
            $resolver = new LoaderAggregate;
            $resolver->attach(new LoaderMapResource, 100);
            self::$default_resolver = $resolver;
        }

        return self::$default_resolver;
    }
769922
protected function registerException()
    {
        $this->app->singleton('Nano7\Foundation\Contracts\Exception\ExceptionHandler', function ($app) {
            $except = new \Nano7\Foundation\Exception\ExceptionHandler();

            // Verificar se view foi adicionada
            if ($app->resolved('view')) {
                $except->setViewService($app['view']);
            }

            return $except;
        });
    }
270899
public function getErrorProcessor(): MiddlewareInterface
    {
        if (is_null($this->errorProcessor)) {
            if (method_exists($this, 'resolve')) {
                $this->setErrorProcessor($this->resolve(Middleware::class));
            } else {
                $this->setErrorProcessor(new Middleware());
            }
        }

        return $this->errorProcessor;
    }
106723
public function getResolver()
    {
        if ($this->resolver instanceof Resolver) {
            return $this->resolver;
        }

        $factory = new Factory();
        $this->resolver = $factory->createCached($this->getDnsServer(), $this->getLoop());

        return $this->resolver;
    }
784246
public function handleException($exception)
	{
		$response = $this->callCustomHandlers($exception);

		// If one of the custom error handlers returned a response, we will send that
		// response back to the client after preparing it. This allows a specific
		// type of exceptions to handled by a Closure giving great flexibility.
		if ( ! is_null($response))
		{
			$response = $this->prepareResponse($response);
		}

		// If no response was sent by this custom exception handler, we will call the
		// default exception displayer for the current application context and let
		// it show the exception to the user / developer based on the situation.
		else
		{
			$response = $this->displayException($exception);
		}

		return $this->sendResponse($response);
	}
810657
public static function handleFatalError()
    {
        self::$reservedMemory = '';

        if (!$handler = self::$exceptionHandler) {
            return;
        }

        $error = error_get_last();

        if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
            $msg = sprintf('%s: %s', self::getErrorDescription($error['type']), $error['message']);

            if (strpos($error['message'], 'Allowed memory') === 0 || strpos($error['message'], 'Out of memory') === 0) {
                $exception = new ErrorException($msg, 0, $error['type'], $error['file'], $error['line']);
            } else {
                // @todo provide backtrace (through symfony/debug?)
                $exception = new ErrorException($msg, 0, $error['type'], $error['file'], $error['line']);
            }
        }

        if (!isset($exception)) {
            return;
        }

        try {
            $handler($exception);
        } catch (Exception $ex) {
            // Silence any further exceptions
        }
    }
1339336
public function setExceptionHandler(callable $handler = null)
    {
        $prev = $this->exceptionHandler;
        $this->exceptionHandler = $handler;

        return $prev;
    }
405289
public static function get_exception_handler() {
        return function($ex) {
            $info = get_exception_info($ex);

            $logerrmsg = "enrol_paypal IPN exception handler: ".$info->message;
            if (debugging('', DEBUG_NORMAL)) {
                $logerrmsg .= ' Debug: '.$info->debuginfo."\n".format_backtrace($info->backtrace, true);
            }
            error_log($logerrmsg);

            if (http_response_code() == 200) {
                http_response_code(500);
            }

            exit(0);
        };
    }
140929
public function getResolver()
    {
        if ($this->resolver === null) {
            $config = $this->getConfig('resolver');
            if ($config !== null) {
                $this->resolver = $this->buildResolver($config);
            } else {
                throw new RuntimeException('Resolver has not been set.');
            }
        }

        return $this->resolver;
    }
738703
public static function fromInvalidResolver($resolver) : self
    {
        return new self(sprintf(
            'Invalid resolver found, expected `' . ResolverInterface::class . '`, `%s` given.',
            is_object($resolver) ? get_class($resolver) : gettype($resolver)
        ));
    }
174034
public static function setupExceptionHandling() {
        $previous = set_exception_handler(self::$exceptionHandler=__CLASS__.'::handleException');

        /**
         * Detect entering of the script's shutdown phase to be capable of handling destructor exceptions during shutdown
         * differently and avoid otherwise fatal errors. Should be the very first function on the shutdown function stack.
         *
         * @see  http://php.net/manual/en/language.oop5.decon.php
         * @see  ErrorHandler::handleDestructorException()
         */
        register_shutdown_function(function() {
            self::$inShutdown = true;
        });
        return $previous;
    }
404789
protected function handleException($handler, Throwable $exception)
	{
		if($handler instanceof Closure)
		{
			return $handler($exception);
		}

		return $this->handlerFactory($handler)->handle($exception);
	}