diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-01-26 15:51:13 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-01-26 15:51:13 +0100 |
| commit | 20fb4e7c379b79b84d9884d5f2c89d781c5793e2 (patch) | |
| tree | a1eef90680afa2b43cb1ce0a687c837fd78810e7 /src/error.rs | |
| parent | 0a087cd28bbee5fcdffbb9d49b0ba9f413ad7f92 (diff) | |
Document everything 📜
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs index cd107741..b08d27dd 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,22 +1,36 @@ +//! Errors in source code. +//! +//! There are no fatal errors in _Typst_. The document will always compile and +//! yield a layout. However, this is a best effort process and bad things will +//! still generate errors and warnings. + use serde::Serialize; use crate::syntax::span::SpanVec; +/// A spanned list of errors. pub type Errors = SpanVec<Error>; +/// An error that arose in parsing or layouting. #[derive(Debug, Clone, Eq, PartialEq, Serialize)] pub struct Error { + /// An error message describing the problem. pub message: String, + /// How severe / important the error is. pub severity: Severity, } +/// How severe / important an error is. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize)] pub enum Severity { + /// Something in the code is not good. Warning, + /// Something in the code is wrong! Error, } impl Error { + /// Create a new error from message and severity. pub fn new(message: impl Into<String>, severity: Severity) -> Error { Error { message: message.into(), severity } } |
