Trait parol_runtime::Report

source ·
pub trait Report {
    // Provided methods
    fn report_user_error(err: &Error) -> Result<()> { ... }
    fn report_error<T>(err: &ParolError, file_name: T) -> Result<()>
       where T: AsRef<Path> { ... }
}
Expand description

Trait for parol’s error reporting

Implement this trait and provide an own implementation for Report::report_user_error when you want to contribute your own error reporting for your error types.

If you don’t want to report own errors then simply use it’s default implementation like this:

use parol_runtime::Report;
use parol_macros::parol;

struct MyErrorReporter;
impl Report for MyErrorReporter {};

let err = parol!("Crucial problem!");   // Suppose that this error comes from a call of `parse`
MyErrorReporter::report_error(&err, "my_file.xyz").unwrap_or_default();

Provided Methods§

source

fn report_user_error(err: &Error) -> Result<()>

Implement this method if you want to provide your own error reporting for your own error types. Doing so you can hook into the error reporting process.

Examples are parol’s ParolErrorReporter or basic_interpreter’s BasicErrorReporter.

The method’s argument value is obtained from a parol_runtime::ParolError::UserError’s content. It should return Ok(()) if reporting succeeds and an error value if the reporting itself fails somehow.

source

fn report_error<T>(err: &ParolError, file_name: T) -> Result<()>where T: AsRef<Path>,

You don’t need to implement this method because it contains the reporting functionality for errors from parol_runtime itself.

Implementors§