Register the exception handler and the shutdown handler.

@return void
333046
public function register()
    {
        set_exception_handler(new ExceptionHandler($this->request, $this->factory));
        register_shutdown_function(new ShutdownHandler($this->request, $this->factory));
    }
39395
public function register()
    {
        if (!$this->isRegistered) {
            // Workaround PHP bug 42098
            // https://bugs.php.net/bug.php?id=42098
            class_exists("\\Whoops\\Exception\\ErrorException");
            class_exists("\\Whoops\\Exception\\FrameCollection");
            class_exists("\\Whoops\\Exception\\Frame");
            class_exists("\\Whoops\\Exception\\Inspector");

            set_error_handler(array($this, self::ERROR_HANDLER));
            set_exception_handler(array($this, self::EXCEPTION_HANDLER));
            register_shutdown_function(array($this, self::SHUTDOWN_HANDLER));

            $this->isRegistered = true;
        }

        return $this;
    }
182874
public function register()
    {
        $debugLevel = $this->getDebugLevel();

        if ($this->shouldBeDebugging()) {
            ob_start();
            register_shutdown_function(function() {
                if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
                    return;
                }

                $error = error_get_last();
                if (!is_array($error)) {
                    return;
                }

                if (!in_array($error['type'], $this->getFatalErrorsTypes(), true)) {
                    return;
                }

                if (!$this->canCatchTheError($error['file'])) {
                    return;
                }

                $this->handleFatalError(
                    $error['type'],
                    $error['message'],
                    $error['file'],
                    $error['line']
                );
            });
            set_error_handler(array($this, 'handleError'), $debugLevel);
            set_exception_handler(array($this, 'wrapAndHandleException'));

            error_reporting($debugLevel);
            ini_set($debugLevel);
        }
    }
1219450
public function handleShutdown()
    {
        $error = $this->getLastError();

        // Ignore core warnings and errors.
        if ($error && !($error['type'] & (E_CORE_WARNING | E_CORE_ERROR))) {
            $handler = $this->whoopsShutdownHandler;
            $handler();
        }
    }
77343
public function shutdownHandler()
    {
        $error = error_get_last();

        if (isset($error['type']) && in_array($error['type'], $this->getFatalErrorTypes())) {
            $this->log('php_shutdown', $error, 'danger', false);
        }
    }
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;
    }
553697
protected function setErrorHandlers()
    {
        register_shutdown_function(array($this->logger, 'shutdownHandler'));
        set_exception_handler(array($this->logger, 'exceptionHandler'));
        set_error_handler(array($this->logger, 'errorHandler'), error_reporting());
    }
858315
public function handleShutdown()
    {
        if ($exception = error_get_last()) {
            if ($this->isFatal($exception['type'])) {
                $this->record($exception);
                $exception['trace'] = '';
                if ($this->container->runningInConsole()) {
                    $this->renderForConsole($exception);
                }

                if (!$this->container->runningInConsole()) {
                    $this->renderHttpResponse($exception);
                }
            }
        }
    }
245931
private function setup_exception_handler() {
		// Setup our classes default exception handler, in case anything escapes our other catches
		set_exception_handler( array( $this, 'generic_exception_handler' ) );

		// Register an error handler through our Router's catcher
		$this->response->onError( function( $response, $error_message, $error_type, $exception ) {

			// Check if we have a callable handler in our controller
			$callable = $this->get_controller_callable( 'exception_handler' );

			// Did we actually get a callable?
			if ( $callable !== false ) {
				// Call the found handler
				return call_user_func_array(
					$callable, // The array of the callable
					array( $error_message, $error_type, $exception ) // Arguments
				);
			}
			// We didn't get a callable
			else {
				// Pass the exception to our Paulus-defined exception handler
				$this->generic_exception_handler( $exception );
			}
		});
	}
382068
public function register()
    {
        $this->makePath();

        $this->commands([Commands\Generate::class]);

        $this->loadPackages();

        $this->app->bind('exceptions_handlers', function () {
            return $this->exceptions_handlers;
        });
    }
95732
public function handleShutdown()
    {
        $this->canThrowExceptions = false;

        $error = $this->system->getLastError();
        if ($error && Misc::isLevelFatal($error['type'])) {
            $this->handleError($error['type'], $error['message'], $error['file'], $error['line']);
        }
    }
1017883
public function shutdownHandler()
    {
        // Get last error
        if (null === $lastError = error_get_last()) {
            return;
        }

        if ($this->shouldCaptureFatalError($lastError['type'], $lastError['message'])) {
            $exception = new ErrorException(
                @$lastError['message'], 0, @$lastError['type'],
                @$lastError['file'], @$lastError['line']
            );

            $this->exceptionHandler($exception);
        }
    }
1237412
protected function registerCloseCallback()
    {
        $this->swooleServer->on('Close', function ($server, $fd, $reactorId) {
            $this->dispatchEvent('Close', $this, $fd, $reactorId);
        });
    }
1240266
public function handleShutdown()
	{
		$error = error_get_last();

		// If an error has occurred that has not been displayed, we will create a fatal
		// error exception instance and pass it into the regular exception handling
		// code so it can be displayed back out to the developer for information.
		if ( ! is_null($error))
		{
			extract($error);

			if ( ! $this->isFatal($type)) return;

			$this->handleException(new FatalError($message, $type, 0, $file, $line))->send();
		}
	}
1222406
public function shutdownFunction() {
		if(($e=error_get_last()) && $e !== static::$errorAtStart) {
			foreach($this->ignoreDirs as $dir) {
				if(strpos($e['file'], $dir) === 0)
					return;
			}

			while(ob_get_level()) ob_end_clean();
			$exceptionHandler = set_exception_handler(function() {});
			restore_exception_handler();
			$exception = new FatalErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']);
			call_user_func_array($exceptionHandler, [$exception]);
		}
	}
1297581
public function register()
    {
        $this->app->singleton(ExceptionIdentifier::class, function () {
            return new ExceptionIdentifier();
        });

        $this->app->singleton(ExceptionInfoInterface::class, function () {
            $path = __DIR__.'/../resources/errors.json';

            return new ExceptionInfo(realpath($path));
        });

        $this->app->bind(HtmlDisplayer::class, function (Container $app) {
            $info = $app->make(ExceptionInfoInterface::class);
            $generator = $app->make($this->app instanceof LumenApplication ? LumenGenerator::class : LaravelGenerator::class);
            $assets = function ($path) use ($generator) {
                return $generator->asset($path);
            };
            $path = __DIR__.'/../resources/error.html';

            return new HtmlDisplayer($info, $assets, realpath($path));
        });

        $this->app->bind(VerboseFilter::class, function (Container $app) {
            $debug = $app->config->get('app.debug', false);

            return new VerboseFilter($debug);
        });
    }
279951
public function shutdown()
    {
        $exceptions = $this->client_holder->shutdown();

        if ($this->hasLogger()) {
            foreach ($exceptions as $exception) {
                printf(
                    "Exception caught during shutdown: %s\n",
                    (string) $exception
                );
            }

            $this->logger = null;
        }

        $this->client_poolers = [];
        $this->connection->close();
        $this->is_shutdown = true;
    }