-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Milestone
Description
Instead of building errors in different way and everywhere in the code, we take the approach of implementing a file error.rs in each module (such as more or less done in rustc). We use an error enum such as:
enum TypingError {
TypeMismatch(TypeMismatchInfo),
...
}
struct TypeMismatchInfo {
span: Span;
...
}
Each error has a struct containing the relevant information for later printing the error. An error enum must implement a trait to retrieve an error code:
trait ErrorCode {
fn error_code(&self) -> String;
}
That returns the name of the variant, here TypeMismatch. It is used in the error attribute #29.
Each error structure must implement a trait for printing the error:
trait DisplayError {
fn display_error(&self, cx: &ExtCtxt);
}
This is flexible enough to allow different kind of printing, even for a JSON output or for deep explanation (as with --explain in rustc).
Reactions are currently unavailable