Code review comment: Removed the modified error and provided the error generated by tree parser as it is. [`40558c7`](https://github.com/ballerina-platform/ballerina-lang/pull/37273/commits/40558c760c4979669408d0beed2760ea15600a44)

Code under review:
public BalShellGetResultResponse getResult(String source) {
        BalShellGetResultResponse output = new BalShellGetResultResponse();
        PrintStream originalOut = System.out;
        PrintStream originalErr = System.err;
        ConsoleOutCollector consoleOutCollector = new ConsoleOutCollector();
        PrintStream printStreamCollector = new PrintStream(consoleOutCollector, false, StandardCharsets.UTF_8);
        System.setOut(printStreamCollector);
        System.setErr(printStreamCollector);
        try {
            ShellCompilation shellCompilation = evaluator.getCompilation(source);
            
            
            
            if (shellCompilation.getExceptionStatus() == ExceptionStatus.SUCCESS) {
                Optional<PackageCompilation> compilation = shellCompilation.getPackageCompilation();
                Optional<NotebookReturnValue> notebookReturnValue = evaluator.getValueAsObject(compilation);
                if (notebookReturnValue.isPresent() &&
                        notebookReturnValue.get().getExceptionStatus() == ExceptionStatus.SUCCESS) {
                    Object out = notebookReturnValue.get().getResult();
                    output.setValue(out);
                } else if (notebookReturnValue.isPresent() &&
                        notebookReturnValue.get().getExceptionStatus() == ExceptionStatus.INVOKER_FAILED) {
                    throw new InvokerException();
                }
            
            } else if (shellCompilation.getExceptionStatus() == ExceptionStatus.SNIPPET_FAILED) {
                throw new SnippetException();
            } else if (shellCompilation.getExceptionStatus() == ExceptionStatus.TREE_PARSER_FAILED) {
                if (source.startsWith(COMMAND_PREFIX)) {
                    List<Diagnostic> diagnostics = Collections.singletonList(Diagnostic.error(
                            "Please note that Ballerina shell commands are not supported in here."));
                    output.addOutputDiagnostics(diagnostics);
                    evaluator.resetDiagnostics();
                }
                throw new TreeParserException();
            } else {
                throw new InvokerException();
            }
        } catch (InvokerPanicException ignored) {
            
        } catch (Exception error) { 
            output.addError(error.getMessage());
        } finally {
            output.setConsoleOut(consoleOutCollector.getLines());
            output.addOutputDiagnostics(evaluator.diagnostics());
            output.setMetaInfo(
                    evaluator.newVariableNames(),
                    evaluator.newModuleDeclarations()
            );
            evaluator.resetDiagnostics();
            evaluator.clearPreviousVariablesAndModuleDclnsNames();
            printStreamCollector.close();
            System.setOut(originalOut);
            System.setErr(originalErr);
        }
        return output;
    }

Line commented on: "Please note that Ballerina shell commands are not supported in here."));

Revised code:
public BalShellGetResultResponse getResult(String source) {
        BalShellGetResultResponse output = new BalShellGetResultResponse();
        PrintStream originalOut = System.out;
        PrintStream originalErr = System.err;
        ConsoleOutCollector consoleOutCollector = new ConsoleOutCollector();
        PrintStream printStreamCollector = new PrintStream(consoleOutCollector, false, StandardCharsets.UTF_8);
        System.setOut(printStreamCollector);
        System.setErr(printStreamCollector);
        try {
            ShellCompilation shellCompilation = evaluator.getCompilation(source);
            
            
            
            if (shellCompilation.getExceptionStatus() == ExceptionStatus.SUCCESS) {
                Optional<PackageCompilation> compilation = shellCompilation.getPackageCompilation();
                Optional<NotebookReturnValue> notebookReturnValue = evaluator.getValueAsObject(compilation);
                if (notebookReturnValue.isPresent() &&
                        notebookReturnValue.get().getExceptionStatus() == ExceptionStatus.SUCCESS) {
                    Object out = notebookReturnValue.get().getResult();
                    output.setValue(out);
                } else if (notebookReturnValue.isPresent() &&
                        notebookReturnValue.get().getExceptionStatus() == ExceptionStatus.INVOKER_FAILED) {
                    throw new InvokerException();
                }
            
            } else if (shellCompilation.getExceptionStatus() == ExceptionStatus.SNIPPET_FAILED) {
                throw new SnippetException();
            } else if (shellCompilation.getExceptionStatus() == ExceptionStatus.TREE_PARSER_FAILED) {
                if (source.startsWith(COMMAND_PREFIX)) {
                    
                    evaluator.resetDiagnostics();
                }
                throw new TreeParserException();
            } else {
                throw new InvokerException();
            }
        } catch (InvokerPanicException ignored) {
            
        } catch (Exception error) { 
            output.addError(error.getMessage());
        } finally {
            output.setConsoleOut(consoleOutCollector.getLines());
            output.addOutputDiagnostics(evaluator.diagnostics());
            output.setMetaInfo(
                    evaluator.newVariableNames(),
                    evaluator.newModuleDeclarations()
            );
            evaluator.resetDiagnostics();
            evaluator.clearPreviousVariablesAndModuleDclnsNames();
            printStreamCollector.close();
            System.setOut(originalOut);
            System.setErr(originalErr);
        }
        return output;
    }