pub struct CompilerError {
pub details: Vec<CompilerErrorOrDiagnostic>,
pub is_thrown: bool,
}Expand description
Aggregate compiler error - can contain multiple diagnostics. This is the main error type thrown/returned by the compiler.
Fields§
§details: Vec<CompilerErrorOrDiagnostic>§is_thrown: boolWhen false, this error was accumulated on the Environment via
record_error() / record_diagnostic() and returned at the end
of the pipeline. In TS, CompileUnexpectedThrow is only emitted
for errors that are thrown (not accumulated). Defaults to true
because errors created directly (e.g., via ? from a pass) are
analogous to thrown errors in the TS code.
Implementations§
Source§impl CompilerError
impl CompilerError
pub fn new() -> Self
pub fn push_diagnostic(&mut self, diagnostic: CompilerDiagnostic)
pub fn push_error_detail(&mut self, detail: CompilerErrorDetail)
pub fn has_errors(&self) -> bool
pub fn has_any_errors(&self) -> bool
Sourcepub fn has_invariant_errors(&self) -> bool
pub fn has_invariant_errors(&self) -> bool
Check if any error detail has Invariant category.
pub fn merge(&mut self, other: CompilerError)
Sourcepub fn is_all_non_invariant(&self) -> bool
pub fn is_all_non_invariant(&self) -> bool
Check if all error details are non-invariant. In TS, this is used to determine if an error thrown during compilation should be logged as CompileUnexpectedThrow.
Sourcepub fn to_string_for_event(&self) -> String
pub fn to_string_for_event(&self) -> String
Format as a string matching the TS CompilerError.toString() output.
Used for the data field of CompileUnexpectedThrow events.
Format per detail: "Category: reason. Description. (line:column)"
Multiple details are joined with "\n\n".
Trait Implementations§
Source§impl Clone for CompilerError
impl Clone for CompilerError
Source§fn clone(&self) -> CompilerError
fn clone(&self) -> CompilerError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompilerError
impl Debug for CompilerError
Source§impl Default for CompilerError
impl Default for CompilerError
Source§impl Display for CompilerError
impl Display for CompilerError
Source§impl Error for CompilerError
impl Error for CompilerError
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()
Source§impl From<CompilerDiagnostic> for CompilerError
impl From<CompilerDiagnostic> for CompilerError
Source§fn from(diagnostic: CompilerDiagnostic) -> Self
fn from(diagnostic: CompilerDiagnostic) -> Self
Source§impl From<CompilerError> for CompilerDiagnostic
Allow ? to convert a CompilerError into a CompilerDiagnostic
when the enclosing function returns Result<T, CompilerDiagnostic>.
impl From<CompilerError> for CompilerDiagnostic
Allow ? to convert a CompilerError into a CompilerDiagnostic
when the enclosing function returns Result<T, CompilerDiagnostic>.
This typically happens when record_error() returns Err(CompilerError)
for an Invariant error, and the calling function already returns
Result<T, CompilerDiagnostic>. The conversion extracts the first
error detail from the aggregate error.