Register the error and exception handlers.

@return void
12799
public function register()
    {
        $level = -1;
        if (isset($this->_options['errorLevel'])) {
            $level = $this->_options['errorLevel'];
        }
        error_reporting($level);
        set_error_handler([$this, 'handleError'], $level);
        set_exception_handler([$this, 'wrapAndHandleException']);
        register_shutdown_function(function () {
            if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && $this->_handled) {
                return;
            }
            $megabytes = Configure::read('Error.extraFatalErrorMemory');
            if ($megabytes === null) {
                $megabytes = 4;
            }
            if ($megabytes > 0) {
                $this->increaseMemoryLimit($megabytes * 1024);
            }
            $error = error_get_last();
            if (!is_array($error)) {
                return;
            }
            $fatals = [
                E_USER_ERROR,
                E_ERROR,
                E_PARSE,
            ];
            if (!in_array($error['type'], $fatals, true)) {
                return;
            }
            $this->handleFatalError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line']
            );
        });
    }
1133648
protected function registerHandler()
	{
		$this->app['exception'] = $this->app->share(function($app)
		{
			return new Handler($app, $app['exception.plain'], $app['exception.debug']);
		});
	}
293569
public function register()
    {
        if (!$this->registered) {
            error_reporting($this->errorLevel);
            set_exception_handler([$this, 'handleException']);
            set_error_handler([$this, 'handleError'], $this->errorLevel);
            register_shutdown_function([$this, 'handleShutdown']);

            $this->registered = true;
        }

        return $this;
    }
365035
protected function registerExceptionHandler()
    {
        $this->exceptionHandler = ExceptionHandler::register(true);
        $this->exceptionHandler->setDisplayer($this->displayer);
    }
639039
public function register()
    {
        $this->registerLockdownConfiguration();
        $this->registerLockdownFacade();
        $this->registerUserProvider();
        $this->registerRoleProvider();
        $this->registerPermissionProvider();
        $this->registerLockdown();
        $this->registerLockdownGuard();
        $this->registerCommands();
    }
846322
protected function registerErrorHandling()
    {
        error_reporting(-1);

        set_error_handler(function ($level, $message, $file = '', $line = 0) {
            if (error_reporting() & $level) {
                // ignore ACF non-numeric issue on PHP 7.1.x until it is fixed
                if (stripos($file, 'acf-repeater/views/field.php') !== false && $message === 'A non-numeric value encountered') {
                    return false;
                }
                // ignore wordpress test cases
                if ($message === '/tmp/wordpress-tests-lib/includes/../data/themedir1 is not readable') {
                    return false;
                }

                throw new ErrorException($message, 0, $level, $file, $line);
            }
        });

        set_exception_handler(function ($e) {
            $this->handleUncaughtException($e);
        });

        register_shutdown_function(function () {
            $this->handleShutdown();
        });
    }
1113992
public function register()
    {
        if (!$this->isLumen()) {
            $this->publishes([
                __DIR__ . '/../config/safequeue.php' => config_path('safequeue.php'),
            ], 'safequeue');
        }

        $this->mergeConfigFrom(
            __DIR__ . '/../config/safequeue.php', 'safequeue'
        );

        $this->registerWorker();
    }
271015
protected function registerShutdownHandlers()
    {
        $self = $this;
        register_shutdown_function(function () use ($self) {
            if (($error = error_get_last()) && in_array($error['type'], array(E_PARSE, E_ERROR, E_USER_ERROR))) {
                $self->shutdown(1, $error);
            } else {
                $self->emit('finish', 0);
                $self->shutdown();
            }

            if (!is_resource($self->queue) || !msg_stat_queue($self->queue)) {
                return;
            }

            msg_remove_queue($self->queue);
        });
    }
1283089
protected function registerFatalHandler()
    {
        $error = $this;

        // When shutdown, the current working directory will be set to the web
        // server directory, store it for later use
        $cwd = getcwd();

        register_shutdown_function(function () use ($error, $cwd) {
            $e = error_get_last();
            if (!$e || !in_array($e['type'], array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) {
                // No error or not fatal error
                return;
            }

            ob_get_length() && ob_end_clean();

            // Reset the current working directory to make sure everything work as usual
            chdir($cwd);

            $exception = new \ErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']);

            if ($error->triggerHandler('fatal', $exception)) {
                // Handled!
                return;
            }

            // Fallback to error handlers
            if ($error->triggerHandler('error', $exception)) {
                // Handled!
                return;
            }

            // Fallback to internal error Handlers
            $error->internalHandleException($exception);
        });
    }
324956
public function startExceptionHandling()
    {
        $this['exception']->register($this->environment());

        //
        $debug = $this['config']['app.debug'];

        $this['exception']->setDebug($debug);
    }
469800
public function register()
    {
        $this->bindContracts();
        $this->bindConfig();
        $this->bindSender();
        $this->bindResolver();
        $this->bindNotifynder();

        $this->registerSenders();
    }
849393
public function register()
    {
        $this->resolveDirectories();

        $this->tryRequireHelpers(self::ON_REGISTER);
        $this->tryRegisterProviders(self::ON_REGISTER);

        if (method_exists($this, $this->bootingMethod)) {
            $this->app->booting(function (Application $app) {
                $app->call([$this, $this->bootingMethod]);
            });
        }

        if (method_exists($this, $this->bootedMethod)) {
            $this->app->booted(function (Application $app) {
                $app->call([$this, $this->bootedMethod]);
            });
        }

        // Config
        $this->registerConfigFiles();

        // Middlewares
        if (!$this->app->runningInConsole()) {
            $router = $this->app->make('router');
            $kernel = $this->app->make('Illuminate\Contracts\Http\Kernel');

            foreach ($this->prependMiddleware as $middleware) {
                $kernel->prependMiddleware($middleware);
            }

            foreach ($this->middleware as $middleware) {
                $kernel->pushMiddleware($middleware);
            }

            foreach ($this->routeMiddleware as $key => $middleware) {
                $router->middleware($key, $middleware);
            }
        }

        // Container bindings and aliases
        foreach ($this->bindings as $binding => $class) {
            $this->app->bind($binding, $class);
        }

        foreach ($this->weaklings as $binding => $class) {
            $this->bindIf($binding, $class);
        }

        foreach (['share' => $this->share, 'shared' => $this->shared] as $type => $bindings) {
            foreach ($bindings as $binding => $class) {
                $this->share($binding, $class, [], $type === 'shared');
            }
        }

        foreach ($this->singletons as $binding => $class) {
            if ($this->strict && !class_exists($class) && !interface_exists($class)) {
                throw new \Exception(get_called_class().": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled");
            }
            $this->app->singleton($binding, $class);
        }

        foreach ($this->aliases as $alias => $full) {
            if ($this->strict && !class_exists($full) && !interface_exists($full)) {
                throw new \Exception(get_called_class().": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled");
            }
            $this->app->alias($alias, $full);
        }

        // Commands
        if ($this->app->runningInConsole()) {
            foreach ($this->findCommands as $path) {
                $dir = path_get_directory((new ReflectionClass(get_called_class()))->getFileName());
                $classes = $this->findCommandsIn(path_join($dir, $path), $this->findCommandsRecursive);

                $this->commands = array_merge($this->commands, $classes);
            }
            if (is_array($this->commands) && count($this->commands) > 0) {
                $commands = [];
                foreach ($this->commands as $k => $v) {
                    if (is_string($k)) {
                        $this->app[ $this->commandPrefix.$k ] = $this->app->share(function ($app) use ($k, $v) {
                            return $app->build($v);
                        });

                        $commands[] = $this->commandPrefix.$k;
                    } else {
                        $commands[] = $v;
                    }
                }
                $this->commands($commands);
            }
        }
        // Facades
        if (class_exists('Illuminate\Foundation\AliasLoader')) {
            \Illuminate\Foundation\AliasLoader::getInstance($this->facades)->register();
        }

        // Helpers
        $this->tryRequireHelpers(self::ON_REGISTERED);

        $this->tryRegisterProviders(self::ON_REGISTERED);

        return $this->app;
    }
908678
def register_errors_handler(self, callback, *custom_filters, exception=None, run_task=None, **kwargs):
        
        filters_set = self.filters_factory.resolve(self.errors_handlers,
                                                   *custom_filters,
                                                   exception=exception,
                                                   **kwargs)
        self.errors_handlers.register(self._wrap_async_task(callback, run_task), filters_set)
23715
public function register()
    {
        $this->app['events']->listen(JobProcessing::class, function () {
            $connection = $this->app['config']->get('queue.failed.connection', null);
            $tableName  = $this->app['config']->get('queue.failed.table', 'failed_jobs');

            $schema = $this->app['registry']
                ->getConnection($connection)
                ->getSchemaManager();

            if (!$schema->tablesExist($tableName)) {
                $schema->createTable(
                    (new FailedJobTable($tableName))->build()
                );
            }
        });
    }
50474
protected function initSystemHandlers()
    {
        if (MINDY_ENABLE_EXCEPTION_HANDLER || MINDY_ENABLE_ERROR_HANDLER) {
            $handler = Creator::createObject($this->errorHandlerConfig);
            if (MINDY_ENABLE_EXCEPTION_HANDLER) {
                set_exception_handler([$handler, 'handleException']);
            }
            if (MINDY_ENABLE_ERROR_HANDLER) {
                set_error_handler([$handler, 'handleError'], error_reporting());
            }
        }
    }
184072
protected function bootErrorHandling()
    {
        // Register error handler
        $errorHandler = Injector::inst()->get(ErrorHandler::class);
        $errorHandler->start();

        // Register error log file
        $errorLog = Environment::getEnv('SS_ERROR_LOG');
        if ($errorLog) {
            $logger = Injector::inst()->get(LoggerInterface::class);
            if ($logger instanceof Logger) {
                $logger->pushHandler(new StreamHandler($this->basePath . '/' . $errorLog, Logger::WARNING));
            } else {
                user_error("SS_ERROR_LOG setting only works with Monolog, you are using another logger", E_USER_WARNING);
            }
        }
    }
333046
public function register()
    {
        set_exception_handler(new ExceptionHandler($this->request, $this->factory));
        register_shutdown_function(new ShutdownHandler($this->request, $this->factory));
    }