Focus question: How do other programming languages manage diagnostics (errors, warnings, etc.)
Gleam
Gleam’s Diagnostic struct:
// TODO: split this into locationed diagnostics and locationless diagnostics
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Diagnostic {
pub title: String,
pub text: String,
pub level: Level,
pub location: Option<Location>,
pub hint: Option<String>,
}title- used as the messagetext- can be used as a “help” messagelevel- two levels: error and warninglocation- the location of the diagnostichint- an optional hint for how to fix the diagnostic
Other random notes
- Gleam uses
ecow::EcoStringso that each diagnostic can store a reference to the source - Gleam uses
thiserrorfor its errors - Gleam uses ANSI codes in its diagnostic displays (using
colorterm)