public static function renderErrorView(
        $sView,
        $aData = [],
        $bFlushBuffer = true
    ) {

        //  Flush the output buffer
        if ($bFlushBuffer) {
            $sObContents = ob_get_contents();
            if (!empty($sObContents)) {
                ob_clean();
            }
        }

        $oInput = Factory::service('Input');
        $sType  = $oInput::isCli() ? 'cli' : 'html';
        $aPaths = [];

        $oRouter     = Factory::service('Router');
        $sController = ucfirst($oRouter->fetch_class());

        if (class_exists($sController)) {
            $oReflection     = new \ReflectionClass($sController);
            $sModuleViewPath = preg_replace('/controllers$/', '', dirname($oReflection->getFileName()));
            $aPaths[]        = implode(DIRECTORY_SEPARATOR, [
                rtrim($sModuleViewPath, DIRECTORY_SEPARATOR),
                'views',
                'errors',
                $sType,
                $sView . '.php',
            ]);
        }

        //  App generic
        $aPaths[] = implode(DIRECTORY_SEPARATOR, [
            NAILS_APP_PATH . 'application',
            'views',
            'errors',
            $sType,
            $sView . '.php',
        ]);

        //  Nails
        $aPaths[] = implode(DIRECTORY_SEPARATOR, [
            rtrim(NAILS_COMMON_PATH, DIRECTORY_SEPARATOR),
            'views',
            'errors',
            $sType,
            $sView . '.php',
        ]);

        $sValidPath = null;
        foreach ($aPaths as $sPath) {
            if (file_exists($sPath)) {
                $sValidPath = $sPath;
                break;
            }
        }

        if ($sValidPath) {

            $oView = Factory::service('View');
            $oView->setData($aData);
            echo $oView->load($sValidPath, [], true);

        } else {
            static::halt('404 Page Not Found', '', HttpCodes::STATUS_NOT_FOUND);
        }
    }