Detect when the request has not been handled and throw an exception

@return void
976516
public function detectWhenRequestHasNotBeenHandled()
    {
        add_action('wp_footer', function () {
            $this->requestHasBeenHandled();
        });

        add_action('shutdown', function () {
            if (!$this->hasRequestBeenHandled()) {
                if ($this->has('__wp-controller-miss-template') && $this->has('__wp-controller-miss-controller')) {
                    wp_die(
                        'Loaded template <code>' .
                        $this->get('__wp-controller-miss-template') .
                        '</code> but couldn\'t find class <code>' .
                        $this->get('__wp-controller-miss-controller') .
                        '</code>'
                    );
                }
            }
        });
    }
349013
protected function checkRequest()
    {
        if (preg_match(CKFINDER_REGEX_INVALID_PATH, $this->_currentFolder->getClientPath())) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }

        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();

        if (is_null($_resourceTypeConfig)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_TYPE);
        }

        $_clientPath = $this->_currentFolder->getClientPath();
        $_clientPathParts = explode("/", trim($_clientPath, "/"));
        if ($_clientPathParts) {
            foreach ($_clientPathParts as $_part) {
                if ($_resourceTypeConfig->checkIsHiddenFolder($_part)) {
                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
                }
            }
        }

        if (!is_dir($this->_currentFolder->getServerPath())) {
            if ($_clientPath == "/") {
                if (!CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($this->_currentFolder->getServerPath())) {
                    /**
                     * @todo handle error
                     */
                }
            }
            else {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
            }
        }
    }
997014
public function handleRequest()
    {
        $request = $this->prepareRequest();
        $version = $request['version'];
        $queryConfiguration = $request['queryConfiguration'];

        $data = $this->provider->process();
        return $version->createResponse($data, $queryConfiguration, $this->columnConfigurations);
    }
186218
public function RequestHandle()
    {
        if ($this->visible == false) {
            return;
        }

        $child = next(WebApplication::getApplication()->getRequest()->request_c);

        if ($child != false && $this->components[$child] instanceof Requestable) {
            $this->components[$child]->RequestHandle();
        }
    }
941585
public function handleShutdown()
    {
        // If we reached this step, we are in shutdown handler.
        // An exception thrown in a shutdown handler will not be propagated
        // to the exception handler. Pass that information along.
        $this->canThrowExceptions = false;

        $error = error_get_last();
        if ($error && Misc::isLevelFatal($error['type'])) {
            // If there was a fatal error,
            // it was not handled in handleError yet.
            $this->handleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line']
            );
        }
    }
672650
public function tryAnException()
    {
        try {
            $iterator = $this->endpoint->listRecords('foobardoesnotexist');
            $iterator->current();
        } catch (\Phpoaipmh\Exception\OaipmhException $e) {
            throw $e;
        }
    }
1263386
public function onHandshake()
    {
        if (!isset($this->route)) {
            return;
        }
        $this->route->onWakeup();
        try {
            $this->route->onHandshake();
        } catch (\Exception $e) {
            Daemon::uncaughtExceptionHandler($e);
        }
        $this->route->onSleep();
    }
1295084
private function handle(){
        $params = [
            "start"     => null,
            "finish"    => null,
            "response"  => null,
            "error"     => null,
        ];

        try{
            $params["start"]    = microtime(true);
            $params["response"] = $this->handler->handle($this->request);
        }catch(\Throwable $e){
            $params["error"]    = $e;
            $this->error        = $e;
        }finally{
            $params["finish"]   = microtime(true);
        }

        $this->event(new Event("response.handle.after", $params));

        return $params["response"];
    }
696038
protected function registerErrorHandle(): void
    {
        \set_error_handler([$this, 'handleError']);
        \set_exception_handler([$this, 'handleException']);
        \register_shutdown_function(function () {
            if ($e = \error_get_last()) {
                $this->handleError($e['type'], $e['message'], $e['file'], $e['line']);
            }
        });
    }
183971
protected function handleRequest()
    {
        try {
            $request = $this->getRequest();
            if ($request->isParseError() === true) {
                throw new ParseErrorException();
            }
            $this->events->trigger('sendRequest.pre', $this, array('methode' => $request->getMethod()));
            if (($ret = $this->getParentHandle()) instanceof RPCERROR && ($ret = $ret->getData()) instanceof \Exception) {
                throw $ret;
            }
        } catch (AbstractException $e) {
            if(isset($this->options['log'])) {
                $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage());
            }
            return $this->fault($e->getMessage(), $e->getCode());
        } catch (\Exception $e) {
            if(isset($this->options['log'])) {
                $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getTrace());
            }
            return ((isset($this->options['environment']) && $this->options['environment'] === "dev")) ? $this->fault('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getCode(), $e->getTrace()) : $this->fault('Internal error', RPCERROR::ERROR_INTERNAL);
        }
    }
33738
protected function _checkRequestMethods()
    {
        $action = $this->_action();
        $apiConfig = $action->getConfig('api');

        if (!isset($apiConfig['methods'])) {
            return false;
        }

        $request = $this->_request();
        foreach ($apiConfig['methods'] as $method) {
            if ($request->is($method)) {
                return true;
            }
        }

        throw new MethodNotAllowedException();
    }
391536
public function maybe_handle() {
		if ( $this->is_process_running() ) {
			// Background process already running.
			wp_die();
		}

		if ( $this->is_queue_empty() ) {
			// No data to process.
			wp_die();
		}

		check_ajax_referer( $this->identifier, 'nonce' );

		$this->handle();

		wp_die();
	}
925913
public function handleRequest(): self
    {
        if ($this->params->getBotParam('webhook.url')) {
            return $this->handleWebhook();
        }

        if ($loop_time = $this->getLoopTime()) {
            return $this->handleGetUpdatesLoop($loop_time, $this->getLoopInterval());
        }

        return $this->handleGetUpdates();
    }
806764
public function handle() {
		if (\Skeleton\Core\Hook::exists('handle_error', [$this->exception])) {
			// If the error is handled within the application, no need to continue
			// internally.
			$this->last_handler = true;
			\Skeleton\Core\Hook::call('handle_error', [$this->exception]);
		}
	}
741246
protected function _exception() {
        $url = '.' . $this->request->src . '.' . $this->request->controller . '.' . $this->request->action;

        if (in_array($url, $this->config['user']['security']['spam']['config']['exception'])) {
            $this->_exception = true;
        }

        return $this->_exception;
    }
724432
protected function notFound()
    {
        // Set the default not found response
        $this->response->setContent('File not found');
        $this->response->headers->set('content-type', 'text/html');
        $this->response->setStatusCode(Response::HTTP_NOT_FOUND);

        // Execute the user defined notFound callback
        if (is_callable($this->notFound)) {
            $this->response = call_user_func($this->notFound, $this->response);
        }
    }
297843
static function hasErrorAccrued()
    {
        if (!self::hasHandling())
            return false;

        $stack = self::$_STACK[self::getStackNum()-1];
        return $stack['has_handled_error'];
    }