Returns a Whoops handler.

@return \Whoops\Handler\HandlerInterface
965004
protected function getWhoopsHandler(): WhoopsHandlerInterface
	{
		if($this->returnAsJson())
		{
			return new JsonResponseHandler;
		}

		if($this->returnAsXml())
		{
			return new XmlResponseHandler;
		}

		$handler = new PrettyPageHandler;

		$handler->handleUnconditionally(true);

		$handler->setApplicationPaths([$this->app->getPath()]);

		$handler->setPageTitle('Error');

		$blacklist = $this->app->getConfig()->get('application.error_handler.debug_blacklist');

		if(!empty($blacklist))
		{
			foreach($blacklist as $superglobal => $keys)
			{
				foreach($keys as $key)
				{
					$handler->blacklist($superglobal, $key);
				}
			}
		}

		return $handler;
	}
798118
public function use_default_handler( HandlerInterface $handler = NULL ) {

		static $done = FALSE;
		if ( $done ) {
			return $this;
		}

		$done = TRUE;

		add_action(
			HandlersRegistry::ACTION_REGISTER,
			function ( HandlersRegistry $registry ) use ( $handler ) {

				$handler = DefaultHandlerFactory::with_default_handler( $handler )
					->create_default_handler();

				$registry->add_handler( $handler, HandlersRegistry::DEFAULT_NAME );
			},
			1
		);

		return $this;
	}
1015028
public function registerErrorHandler()
    {
        $whoops = new \Whoops\Run();
        $configuration = $this->getConfiguration();

        if (isset($configuration['debug']) && $configuration['debug']) {
            $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
        } else {
            $whoops->pushHandler(new \Whoops\Handler\CallbackHandler(function ($exception) {
                $this->logger->error($exception->getMessage(), compact('exception'));

                $request = $this->container->get('request');
                $response = $this->container->get('response');
                $view = $this->container->get('view');
                $errorInfo = ['message' => $exception->getMessage()];

                if (is_a($exception, HttpException::class)) {
                    $errorInfo['code'] = $exception->getCode();
                } else {
                    $errorInfo['code'] = 500;
                }

                $headerAccept = $request->getHeader('Accept');
                if (in_array('application/json', $headerAccept)) {
                    $response = $response->withStatus($errorInfo['code']);
                    $response->getBody()->write(json_encode($errorInfo));

                    $response = $response->withHeader('Content-Type', 'application/json');
                } else {
                    $response = $view->render($response, 'error', $errorInfo);
                }

                $this->emitResponse($response);

                return \Whoops\Handler\Handler::DONE;
            }));
        }

        $whoops->register();
    }
9891
public function getHandle()
    {
        if (isset($this->_identity_key)) {
            $handle = $this->getProperty($this->_identity_key);
        } else {
            $handle = parent::getHandle();
        }

        return $handle;
    }
1150601
private function errorHandling(?bool $isConsole = false)
  {
    $this->internalErrors();

    $whoopsRun     = new WhoopsRun;
    $development   = new PrettyPageHandler;
    $errors        = new Error;
    $production    = new CallbackHandler($this->uiRegister());
    $cliErrors     = new CallbackHandler($this->cliRegister());

    $development->setPageTitle("Whoops! There was a problem.");

    foreach ($_ENV as $key => $value) {
      if (str_contains(strtolower($key), ['password', 'key', 'token', 'port', 'user', 'connection', 'host', 'database'])) {
        $development->blacklist('_ENV', $key);
      }
    }

    foreach ($_SERVER as $key => $value) {
      if (str_contains(strtolower($key), ['filename', 'script_name', 'php_self', 'document', 'password', 'key', 'token', 'port', 'user', 'connection', 'host', 'database'])) {
        $development->blacklist('_SERVER', $key);
      }
    }

    $whoopsRun->pushHandler(
      $isConsole ? $cliErrors : (config('app.debug') ? $development : $production)
    );

    if (Misc::isAjaxRequest()) {
      $errors->ajax = true;
    }

    $bugsnag = \Bugsnag\Client::make();
    \Bugsnag\Handler::register($bugsnag);

    $whoopsRun->handleShutdown();
    $whoopsRun->register();
  }
125830
protected function registerWhoops()
	{
		$this->registerWhoopsHandler();

		$this->app['whoops'] = $this->app->share(function($app)
		{
			// We will instruct Whoops to not exit after it displays the exception as it
			// will otherwise run out before we can do anything else. We just want to
			// let the framework go ahead and finish a request on this end instead.
			with($whoops = new Run)->allowQuit(false);

			$whoops->writeToOutput(false);

			return $whoops->pushHandler($app['whoops.handler']);
		});
	}
121153
public function getClient() {
		if (!$this->client) {
			// Create custom handler stack with middlewares
			$stack = HandlerStack::create();

			$context = $this;
			$stack->push(Middleware::mapResponse(function (ResponseInterface $response) use ($context) {
   				// If a new version of this accessor is available, store its COID
				if ($response->hasHeader('C-Accessor-Latest-Version'))
      				$context->setLatestAccessorVersionCOID(
						new IRI($response->getHeaderLine('C-Accessor-Latest-Version')));
    			return $response;
			}));

			// Prepare client options
			$options = [
				'base_uri' => str_replace('{aauid}', AAUIDParser::getAAUID($this->getAAUID()), $this->agwBaseUrl),
				'headers' => [
					'Authorization' => 'Bearer '.$this->getAccessToken()
				],
				'handler' => $stack
			];
			if (isset($this->request) && $this->request->hasHeader('X-Forwarded-For')) {
				$options['headers']['X-Forwarded-For'] = $this->request->getHeaderLine('X-Forwarded-For');				
			}

			// Create client
			$this->client = new Client($options);
		}
		return $this->client;
	}
603013
protected function getHandler() : HandlerStack
    {
        $stack = HandlerStack::create();

        $stack->push(
            Middleware::mapResponse(function (ResponseInterface $response) {
                $handler = $this->getResponseHandler();

                return new $handler($response);
            }),
            'bitcoind_response'
        );

        return $stack;
    }
675450
public function register(Container $container)
    {
        $config = $container->get('config');

        if ($config->get('system.debug')) {
            $whoops = new Whoops();

            $handler = new PrettyPageHandler();
            $handler->setEditor($config->get('whoops.editor', 'phpstorm'));

            $whoops->pushHandler($handler);

            $container->share(Whoops::class, $whoops)
                ->alias('whoops', Whoops::class);

            $container->share(PrettyPageHandler::class, $handler)
                ->alias('whoops.handler', PrettyPageHandler::class);
        }
    }
738163
protected function loadWhoopsErrorHandler()
	{
		$run = new \Whoops\Run;
		$run->pushHandler(new \Whoops\Handler\PrettyPageHandler);
		$run->register();
		return $run;
	}
221743
protected function getHandler()
    {
        switch ($this->getConnectionStatus()) {
            case static::CONNECTION_STATUS_NONE:
                $this->launch();
                // no break
            case static::CONNECTION_STATUS_GOOD:
                return $this->handler;
            case static::CONNECTION_STATUS_BAD:
                throw new ConnectionException(
                    "Connection problem. Read your server's log about this, I have no more informations."
                );
            case static::CONNECTION_STATUS_CLOSED:
                throw new ConnectionException(
                    "Connection has been closed, no further queries can be sent."
                );
        }
    }
373109
public function afterDetach()
    {
        $handler = $this->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->afterDetach($this);
        }
    }
706449
public function pop()
    {
        $handler = $this->isolator->set_error_handler(function () {});

        if (null !== $handler) {
            $this->isolator->restore_error_handler();
        }

        $this->isolator->restore_error_handler();

        return $handler;
    }
634325
public function get_handler()
    {
        $handler = new PrettyPageHandler();
            
        $handler->addDataTableCallback('$wp_query', [$this, 'add_query']);

        $handler->addDataTableCallback('$post', [$this, 'add_post']);

        $handler->addDataTableCallback('$wp', [$this, 'add_wp']);

        return $handler;
    }
556292
public static function getHandle()
    {
        if (!isset(self::$_dbhnd)) {
            self::$_dbhnd = new \PDO(
                BLConfig::get('db', 'dsn'),
                BLConfig::get('db', 'user'),
                BLConfig::get('db', 'pass')
            );
            self::$_dbhnd->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        }
        return self::$_dbhnd;
    }
4189
public function detectHttpClientHandler()
    {
        $handler = null;
        if (class_exists('GuzzleHttp\Client')) {
            $handler = new GuzzleHttpClient();
        } elseif (function_exists('curl_init')) {
            $handler = new CurlHttpClient();
        } else {
            $handler = new StreamHttpClient();
        }
        return $handler;
    }
24985
public function get_handler_classname() {
        global $CFG;

        if (!empty($CFG->sitepolicyhandler)) {
            $sitepolicyhandlers = $this->get_all_handlers();

            if (!isset($sitepolicyhandlers[$CFG->sitepolicyhandler])) {
                return default_handler::class;

            } else {
                return $sitepolicyhandlers[$CFG->sitepolicyhandler];
            }

        } else {
            return default_handler::class;
        }
    }