{"record":{"id":"b48e06630deed3b5","repo":"stride3d/stride","slug":"error-at-line-column-msg","errorCode":null,"errorMessage":"Error at {line}:{column}: {msg}","messagePattern":"Error at (.+?):(.+?): (.+?)","errorType":"exception","errorClass":"LexerException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/CppNet/Preprocessor.cs","lineNumber":278,"sourceCode":"\t *\n\t * @see #addInput(Source)\n\t */\n\tpublic void addInput(FileInfo file) {\n\t\taddInput(new FileLexerSource(file));\n\t}\n\n\n\t/**\n\t * Handles an error.\n\t *\n\t * If a PreprocessorListener is installed, it receives the\n\t * error. Otherwise, an exception is thrown.\n\t */\n\tprotected void error(int line, int column, String msg) {\n\t\tif (listener != null)\n\t\t\tlistener.handleError(source, line, column, msg);\n\t\telse\n\t\t\tthrow new LexerException(\"Error at \" + line + \":\" + column + \": \" + msg);\n\t}\n\n\t/**\n\t * Handles an error.\n\t *\n\t * If a PreprocessorListener is installed, it receives the\n\t * error. Otherwise, an exception is thrown.\n\t *\n\t * @see #error(int, int, String)\n\t */\n\tprotected void error(Token tok, String msg) {\n\t\terror(tok.getLine(), tok.getColumn(), msg);\n\t}\n\n\t/**\n\t * Handles a warning.\n\t *\n\t * If a PreprocessorListener is installed, it receives the","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/CppNet/Preprocessor.cs#L260-L296","documentation":"Preprocessor.error reports preprocessing errors (raised from error, warning, pop_state, include) at a given line/column. When a PreprocessorListener is installed, the error is delegated to listener.handleError; with no listener, it throws LexerException(\"Error at line:column: msg\") instead. It is the central funnel for directive-level failures such as failed #include or bad directives.","triggerScenarios":"Any preprocessing error with no listener installed: a failed #include (file not found), malformed directives, state errors in pop_state, or error()-reported conditions during pragma handling.","commonSituations":"#include of a shader file whose path is wrong or not in the include search paths; syntax errors in #if/#define expressions; parsing shader sources with a Preprocessor configured without a listener so every warning-level issue escalates to an exception.","solutions":["Install a PreprocessorListener (implementing handleError/handleWarning) so diagnostics are collected instead of thrown at the first problem.","Fix the reported source location: check the file at the given line:column — for includes, verify the path and the include search paths passed to the Preprocessor.","Correct the malformed preprocessor directive (#define, #if, #pragma) flagged by the message.","Wrap preprocessing in try-catch on LexerException and surface line/column information to the user."],"exampleFix":"// before: no listener, first directive error throws\nvar pp = new Preprocessor();\npp.addIncludePath(\"shaders\");\n// after: listener collects errors, preprocessing completes\nvar pp = new Preprocessor();\npp.setListener(new CollectingListener(errors));\npp.addIncludePath(\"shaders\");","handlingStrategy":"try-catch","validationCode":"// Pre-check includes and directives before preprocessing\nforeach (var inc in Regex.Matches(src, @\"#\\s*include\\s*[\\\"<]([^\\\">]+)\"))\n    if (!ResolveOnIncludePaths(inc.Groups[1].Value, includePaths, out _))\n        report($\"Include not found: {inc.Groups[1].Value}\");","typeGuard":null,"tryCatchPattern":"var errors = new List<Diagnostic>();\ntry\n{\n    preprocessor.setListener(new CollectingListener(errors));\n    while ((tok = preprocessor.token()) != null) { /* ... */ }\n}\ncatch (LexerException ex)\n{\n    errors.Add(Diagnostic.Parse(ex.Message)); // \"Error at L:C: msg\"\n}","preventionTips":["Always install a PreprocessorListener so all diagnostics are collected instead of aborting at the first error.","Verify #include paths exist on the configured include search paths before preprocessing.","Sanity-check directive syntax (#define/#if/#pragma) in a pre-pass or linter."],"tags":["preprocessor","directive","include"],"backgroundTag":"file-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}