{"record":{"id":"bd7662daf058534d","repo":"litedb-org/LiteDB","slug":"unknow-token-after-command","errorCode":null,"errorMessage":"Unknow token after command","messagePattern":"Unknow token after command","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"LiteDB.Shell/Utils/StringScanner.cs","lineNumber":126,"sourceCode":"        }\n\n        /// <summary>\n        /// Match if pattern is true in current cursor position. Do not change cursor position\n        /// </summary>\n        public bool Match(Regex regex)\n        {\n            var match = regex.Match(this.Source, this.Index, this.Source.Length - this.Index);\n            return match.Success;\n        }\n\n        /// <summary>\n        /// Throw syntax exception if not terminate string\n        /// </summary>\n        public void ThrowIfNotFinish()\n        {\n            this.Scan(@\"\\s*\");\n\n            if (!this.HasTerminated) throw new Exception(\"Unknow token after command\");\n        }\n    }\n}","sourceCodeStart":108,"sourceCodeEnd":129,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB.Shell/Utils/StringScanner.cs#L108-L129","documentation":"Thrown by StringScanner.ThrowIfNotFinish after consuming trailing whitespace if the scanner has not reached the end of the source. It signals a syntax error: extra, unexpected tokens remain after what should have been a complete command or expression in the shell/SQL parser.","triggerScenarios":"Passing a command string with trailing garbage after a complete token sequence, e.g. a shell or SQL fragment that the grammar parsed fully but left extra characters; malformed input fed to StringScanner-based parsing where ThrowIfNotFinish enforces full consumption.","commonSituations":"Typos adding stray characters after a command; copy-paste of multi-statement text where only one statement was expected; a parser bug that stops early leaving unparsed suffix tokens.","solutions":["Inspect the full input string for stray characters or a second statement concatenated after the first.","Trim and split multi-statement input into individual commands before scanning.","If writing a custom shell command, ensure your Scan/Match consumes all intended tokens so none remain."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before calling ThrowIfNotFinish, peek for leftover non-whitespace\nscanner.Scan(@\"\\s*\");\nif (!scanner.HasTerminated)\n{\n    // report the remaining tokens for easier debugging\n    var rest = scanner.Source.Substring(scanner.Index);\n    throw new Exception($\"Unknow token after command: '{rest}'\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim and split multi-statement input into one command per scan.","When writing shell commands, consume all expected tokens so none remain.","Inspect input for stray characters pasted after a complete command."],"tags":["shell","parser","syntax","stringscanner"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}