pub enum Error {
StreamNotConsumed {
remaining: usize,
},
RecursionLimitExceeded {
depth: usize,
limit: usize,
},
TokenLimitExceeded {
consumed: usize,
limit: usize,
},
}Expand description
Core synkit error type.
This enum captures errors that originate from synkit’s internal operations.
User-defined parsers should define their own error types and implement
From<Error> to convert synkit errors into their domain-specific errors.
§Example
use thiserror::Error;
#[derive(Error, Debug)]
pub enum MyParseError {
#[error("stream not fully consumed: {remaining} tokens remaining")]
StreamNotConsumed { remaining: usize },
#[error("expected {expect}, found {found}")]
Expected { expect: &'static str, found: String },
// ... other variants
}
impl From<synkit::Error> for MyParseError {
fn from(err: synkit::Error) -> Self {
match err {
synkit::Error::StreamNotConsumed { remaining } => {
MyParseError::StreamNotConsumed { remaining }
}
}
}
}Variants§
StreamNotConsumed
The token stream was not fully consumed after parsing.
This error is returned by ensure_consumed() when there are
remaining tokens (excluding whitespace) in the stream.
RecursionLimitExceeded
Recursion limit exceeded during parsing.
This error is returned when nested parsing exceeds the configured maximum recursion depth. This limit exists to prevent stack overflow from deeply nested malicious input.
§Example
Input like [[[[[[...]]]]]] with thousands of nesting levels would
trigger this error with the default limit of 128.
Fields
TokenLimitExceeded
Token limit exceeded during parsing.
This error is returned when the parser has consumed more tokens than the configured maximum. This limit exists to prevent resource exhaustion from extremely long inputs.
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.