stride3d/stride · warning · LexerException
Warning at
Error message
Warning at {line}:{column}: {msg} What it means
Source.warning() emits preprocessor warnings: escalated to error() when werror is set, routed to listener.handleWarning() if a listener exists, and otherwise thrown as LexerException("Warning at line:column: msg"). This is the Source-level counterpart of Preprocessor.warning().
Solutions
- Attach a PreprocessorListener so warnings go to handleWarning
- Turn off werror if warnings should stay non-fatal
- Fix the construct in the shader source flagged at line:column
- Catch LexerException at the preprocessing call site
Example fix
// before var lexer = new FileLexer(file); // no listener // after var lexer = new FileLexer(file); lexer.setListener(new MyListener());
Defensive patterns
Strategy: try-catch
Validate before calling
if (werror && !suppressWarnings) error(line, column, msg); else warn(line, column, msg);
Try / catch
try { Process(lexer); } catch (LexerException e) when (e.Message.StartsWith("Warning at ")) { log.Warn($"Preprocessor warning (fatal, no listener): {e.Message}"); } Prevention
- Install a listener so warnings are non-fatal
- Keep werror off unless warnings-as-errors is intended
When it happens
Trigger: A Lexer/Source subclass (e.g. skipline paths) diagnoses a warning condition with no listener installed, or with werror enabled turning it fatal.
Common situations: Direct use of individual lexer Source objects rather than the top-level Preprocessor; scripts parsing GLSL/HLSL without wiring a listener.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/39f2389053b12ee2.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/CppNet/Source.cs:293
}
}
protected void error(int line, int column, String msg)
{
if(listener != null)
listener.handleError(this, line, column, msg);
else
throw new LexerException("Error at " + line + ":" + column + ": " + msg);
}
protected void warning(int line, int column, String msg)
{
if(werror)
error(line, column, msg);
else if(listener != null)
listener.handleWarning(this, line, column, msg);
else
throw new LexerException("Warning at " + line + ":" + column + ": " + msg);
}
public virtual void close()
{
}
}
}View on GitHub (pinned to 96fad776d2)