404 Page Not Found Handler

@access	private
@param	string	the page
@param 	bool	log error yes/no
@return	string
12956
function show_404($page = '', $log_error = TRUE)
	{
		$heading = "404 Page Not Found";
		$message = "The page you requested was not found.";

		// By default we log this, but allow a dev to skip it
		if ($log_error)
		{
			log_message('error', '404 Page Not Found --> '.$page);
		}

		echo $this->show_error($heading, $message, 'error_404', 404);
		exit;
	}
956240
function show_php_error($severity, $message, $filepath, $line)
	{
		$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];

		$filepath = str_replace("\\", "/", $filepath);

		// For safety reasons we do not show the full file path
		if (FALSE !== strpos($filepath, '/'))
		{
			$x = explode('/', $filepath);
			$filepath = $x[count($x)-2].'/'.end($x);
		}

		if (ob_get_level() > $this->ob_level + 1)
		{
			ob_end_flush();
		}
		ob_start();
		include(APPPATH.'errors/error_php.php');
		$buffer = ob_get_contents();
		ob_end_clean();
		echo $buffer;
	}
797732
function errors() {
        // handling 404 errors from config.express['404_redirect'] property
        if (config['404_redirect']) {
            server.use(function (req, res, next) {
                res.status(302)
                res.writeHead(302, { 'Location': config['404_redirect'] })
                res.end()
            })
        } else {
            server.use(function (req, res, next) {
                res.status(404).send({ message: 'not found' })
            })
        }

        if (errorHandlers.length) {
            for (let eh of errorHandlers) {
                server.use(wrapper(eh))
            }
        }

        //Default error handler
        server.use((err, req, res, next) => {
            if (!config.silent && !errorHandlers.length)
                app.drivers.logger.error('Unhandled server error', err)
            res.status(500)
               .json({
                   message: err.message,
                   stack: process.env.NODE_ENV === 'production' ? undefined : err.stack
               })
        })
    }
1092740
public function notFoundAction()
	{
		$this->getResponse()->setStatusCode(404);
		$this->view->baseUrl = $this->getBasePath();
		$this->layout('layout/noMenuLayout.tpl');
		$this->view->setTemplate("error/404.tpl");
		
		return parent::notFoundAction();
	}
508361
function notFoundRequestHandler( req, res, next ) {
  var err = new Error( 'Not Found' )

  err.statusCode = 404
  next( err )
}
1174469
def view_404(request, url=None):
    
    res = render_to_response("404.html", {"PAGE_URL": request.get_full_path()},
                             context_instance=RequestContext(request))
    res.status_code = 404
    return res
234336
public function redirectNotLogged()
    {
        // TODO: only if GET request!
        http_response_code(403);
        header("Location:".ROOT_URL.$this->loginPageUrl."?".$this->redirectParameter."=".urlencode($_SERVER['REQUEST_URI']));
        exit;
    }
1167774
public function show404($bLogError = true)
    {

        $sPage = ArrayHelper::getFromArray('REQUEST_URI', $_SERVER);

        /**
         * By default we log this, but allow a dev to skip it. Additionally, skip
         * if it's a HEAD request.
         *
         * Reasoning: I often use HEAD requests to check the existence of a file
         * in JS before fetching it. I feel that these shouldn't be logged. A
         * direct GET/POST/etc request to a non-existent file is more  likely a
         * user following a dead link so these _should_ be logged.
         *
         * If you disagree, open up an issue and we'll work something out.
         */

        $sRequestMethod = isset($_SERVER) ? strtoupper(ArrayHelper::getFromArray('REQUEST_METHOD', $_SERVER)) : '';

        if ($bLogError && $sRequestMethod != 'HEAD') {
            log_message('error', '404 Page Not Found --> ' . $sPage);
        }

        // --------------------------------------------------------------------------

        /**
         * Define a constant for easier identification of 404 pages
         */
        Functions::define('NAILS_IS_404', true);

        // --------------------------------------------------------------------------

        /**
         * If the SYSTEM_READY event hasn't been fired then we know that the app's controller hasn't been executed.
         * Instantiate this controller to allow the full application stack to execute, this allows the 404 views to
         * make use of variables defined by /App/Sontroller/Base. Also, load CI's core services as they might not
         * have been loaded.
         */

        $oEvent = Factory::service('Event');
        if (!$oEvent->hasBeenTriggered(Events::SYSTEM_READY)) {

            require_once BASEPATH . 'core/Controller.php';

            load_class('Output', 'core');
            load_class('Security', 'core');
            load_class('Input', 'core');
            load_class('Lang', 'core');

            new Nails404Controller();
        }

        // --------------------------------------------------------------------------

        set_status_header(HttpCodes::STATUS_NOT_FOUND);
        $this->renderErrorView(
            '404',
            [
                'sSubject' => '404 Page Not Found',
                'sMessage' => '',
            ]
        );
        exit(HttpCodes::STATUS_NOT_FOUND);
    }
1087434
private Page notFound(final HttpServletResponse response, final SecurityContext securityContext) throws IOException, FrameworkException {

		final List<Page> errorPages = StructrApp.getInstance(securityContext).nodeQuery(Page.class).and(StructrApp.key(Page.class, "showOnErrorCodes"), "404", false).getAsList();

		for (final Page errorPage : errorPages) {

			if (isVisibleForSite(securityContext.getRequest(), errorPage)) {

				response.setStatus(HttpServletResponse.SC_NOT_FOUND);
				return errorPage;
			}

		}

		response.sendError(HttpServletResponse.SC_NOT_FOUND);

		return null;
	}
636312
def log_request_fail(self, method, full_url, path, body, duration, status_code=None, response=None, exception=None):
        
        # do not log 404s on HEAD requests
        if method == 'HEAD' and status_code == 404:
            return
        logger.warning(
            '%s %s [status:%s request:%.3fs]', method, full_url,
            status_code or 'N/A', duration, exc_info=exception is not None
        )

        # body has already been serialized to utf-8, deserialize it for logging
        # TODO: find a better way to avoid (de)encoding the body back and forth
        if body:
            try:
                body = body.decode('utf-8', 'ignore')
            except AttributeError:
                pass

        logger.debug('> %s', body)

        self._log_trace(method, path, body, status_code, response, duration)

        if response is not None:
            logger.debug('< %s', response)
1210381
function notFound( req, res, next ) {
        var err = new Error( 'Not Found' );
        err.status = 404;

        next( err );
    }
171565
public function error($return = false)
    {
        if (!empty($this->error)) {
            if ($return) {
                return $this->error;
            }
            var_dump($this->error);
            return null;
        }
        return false;
    }
565472
protected function log($log){
        if (is_array($log)) $log = print_r($log,true);
        if ($this->debug) {
            if (function_exists($this->logcallback)) {
                return call_user_func($this->logcallback,$log);
            }elseif ($this->logfile) {
                return file_put_contents($this->logfile, $log."\n", FILE_APPEND) > 0 ? true : false;
            }
        }
        return false;
    }
596154
function error($msg, $section = 'bors', $trace = false, $extra = array())
	{
		static $entered = false;
		if($entered)
			throw new Exception('Reentered logger with '.$msg.' in section '.$section);

		$entered = true;

		try
		{
			$this->logger($section, Logger::ERROR, $trace)->addError($msg, $extra);
		}
		catch(Exception $e)
		{
			echo "Exception while error logging:\n<code><xmp>".$e->getMessage()."</xmp></code>\nFirst error is:\n<xmp>$msg\nin".bors_debug::trace()."</xmp>";
		}

		$entered = false;
	}
95552
def get_or_404(self, ident, description=None):
        """"""

        rv = self.get(ident)
        if rv is None:
            abort(404, description=description)
        return rv
884208
function errorPage(res, err) {
		if (err) {
			console.error(err.message);
			res.send(err, {'Content-Type': 'text/plain'}, 500);
		} else {
			res.send(404);
		}
	}
101058
private function phpErrorHandler(): Closure
    {
        return static function (int $errno, string $errstr, string $errfile, int $errline): bool {
            // Ignore errors that are silenced with '@'
            if (error_reporting() & $errno) {
                throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
            }

            return true;
        };
    }