<commit_before><?php

class SingleModeController extends JCatchControl
{
    public function Handle($request)
    {
        if (jf::CurrentUser()) {

            //This gives absolute path
            $request = jf::$BaseRequest;    //FIXME: Fix JCatchControl so that this is not required

            $relativePath = $this->getRelativePath($request);
            $fileName = LESSON_PATH.$relativePath;

            if (strpos($relativePath, "/static/") !== false) {
                if (file_exists($fileName)) {
                    $FileMan=new \jf\DownloadManager();
                    return $FileMan->Feed($fileName);
                }
            } else {

                $nameOfLesson = basename($relativePath);
                \webgoat\LessonScanner::loadClasses();

                if (strpos($relativePath, "reset/") !== false) {
                    $lessonNameWithNS = "\\webgoat\\".$nameOfLesson;
                    $obj = new $lessonNameWithNS();
                    $obj->reset();

                    echo json_encode(array("status" => true));
                    return true;

                } else {

                    if (((isset($_GET['refresh'])) || (!jf::LoadGeneralSetting("categoryLessons")))) {
                        \webgoat\LessonScanner::run();
                    }

                    $this->allCategoryLesson = jf::LoadGeneralSetting("categoryLessons");
                    try {

                        $lessonObj = \webgoat\LessonScanner::getLessonObject($nameOfLesson);
                        $lessonObj->start();
                        $this->lessonTitle = $lessonObj->getTitle();
                        $this->hints = $lessonObj->getHints();
                        $this->htmlContent = $lessonObj->getContent();
                        $this->nameOfLesson = $nameOfLesson;

                    } catch (Exception $e) {
                        $this->error = "Lesson Not found. Please select a lesson.";
                    }

                    return $this->Present();
                }
            }
        } else {
            $this->Redirect(jf::url().'/user/login');
        }
    }

    private function getRelativePath($request)
    {
        $presentDir = basename(dirname(__FILE__));
        return substr($request, (strpos($request, $presentDir) + strlen($presentDir) + 1));
    }
}<commit_msg>Modified the Exception error message<commit_after><?php

class SingleModeController extends JCatchControl
{
    public function Handle($request)
    {
        if (jf::CurrentUser()) {

            //This gives absolute path
            $request = jf::$BaseRequest;    //FIXME: Fix JCatchControl so that this is not required

            $relativePath = $this->getRelativePath($request);
            $fileName = LESSON_PATH.$relativePath;

            if (strpos($relativePath, "/static/") !== false) {
                if (file_exists($fileName)) {
                    $FileMan=new \jf\DownloadManager();
                    return $FileMan->Feed($fileName);
                }
            } else {

                $nameOfLesson = basename($relativePath);
                \webgoat\LessonScanner::loadClasses();

                if (strpos($relativePath, "reset/") !== false) {
                    $lessonNameWithNS = "\\webgoat\\".$nameOfLesson;
                    $obj = new $lessonNameWithNS();
                    $obj->reset();

                    echo json_encode(array("status" => true));
                    return true;

                } else {

                    if (((isset($_GET['refresh'])) || (!jf::LoadGeneralSetting("categoryLessons")))) {
                        \webgoat\LessonScanner::run();
                    }

                    $this->allCategoryLesson = jf::LoadGeneralSetting("categoryLessons");
                    try {

                        $lessonObj = \webgoat\LessonScanner::getLessonObject($nameOfLesson);
                        $lessonObj->start();
                        $this->lessonTitle = $lessonObj->getTitle();
                        $this->hints = $lessonObj->getHints();
                        $this->htmlContent = $lessonObj->getContent();
                        $this->nameOfLesson = $nameOfLesson;

                    } catch (Exception $e) {
                        //$this->error = "Lesson Not found. Please select a lesson.";
                        $this->error = $e->getMessage();
                    }

                    return $this->Present();
                }
            }
        } else {
            $this->Redirect(jf::url().'/user/login');
        }
    }

    private function getRelativePath($request)
    {
        $presentDir = basename(dirname(__FILE__));
        return substr($request, (strpos($request, $presentDir) + strlen($presentDir) + 1));
    }
}
{'fraction_non_alphanumeric': 0.1315240083507307, 'fraction_numerical': 0.0004175365344467641, 'mean_word_length': 1.474690082644628, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5554917', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1189, 'n_words': 212}