pub struct SyntaxError {
pub line: u32,
pub msg: Vec<u8>,
}Expand description
Syntax error, formatted PUC-style: chunkname:line: msg near 'tok'.
The near part is already baked into msg at construction time.
msg is a raw byte string — PUC 5.1 reports near '\xff'-style errors
with the offending source byte verbatim, and errors.lua 5.1 :20 grep-
matches that pattern. Carrying the message as Vec<u8> lets the lexer
emit those bytes without UTF-8 enforcement getting in the way.
Fields§
§line: u321-based source line where the error was detected. 0 marks a
message that PUC raises without a position prefix (e.g. 5.4’s
“C stack overflow” while parsing, or a memory error).
msg: Vec<u8>Message bytes (PUC-style; may contain non-UTF-8 source bytes).
Implementations§
Source§impl SyntaxError
impl SyntaxError
Sourcepub fn new(line: u32, msg: impl Into<Vec<u8>>) -> Self
pub fn new(line: u32, msg: impl Into<Vec<u8>>) -> Self
Build a SyntaxError at the given line with the given message bytes.
Sourcepub fn unpositioned(msg: impl Into<Vec<u8>>) -> Self
pub fn unpositioned(msg: impl Into<Vec<u8>>) -> Self
An error PUC reports with no chunk:line: prefix.
Trait Implementations§
Source§impl Clone for SyntaxError
impl Clone for SyntaxError
Source§impl Debug for SyntaxError
impl Debug for SyntaxError
Source§impl Display for SyntaxError
impl Display for SyntaxError
impl Eq for SyntaxError
Source§impl Error for SyntaxError
impl Error for SyntaxError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()