diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-01-07 11:33:59 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-01-07 11:33:59 +0200 |
commit | da2793d39aa9142422e319a664cd68534054221a (patch) | |
tree | b083c1b82d95af3648bc8d277b6b0e7df326bf71 | |
parent | d0ff505c89cf6d71c4ba4754af3c71d7f133036e (diff) | |
download | riki-da2793d39aa9142422e319a664cd68534054221a.tar.gz |
refactor: move RikiError::WikitextSyntax into src/parser.rs
Sponsored-by: author
-rw-r--r-- | src/error.rs | 8 | ||||
-rw-r--r-- | src/parser.rs | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/error.rs b/src/error.rs index 6d4d13b..a3944c3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,6 +18,9 @@ pub enum RikiError { #[error(transparent)] Directive(#[from] crate::directive::DirectiveError), + #[error(transparent)] + Parser(#[from] crate::parser::ParserError), + #[error("string formatting error: {0}")] Format(#[source] std::fmt::Error), @@ -36,9 +39,6 @@ pub enum RikiError { #[error(transparent)] PageSpec(#[from] crate::pagespec::PageSpecError), - #[error("failed to parse wikitext, line {0}, column {1}: {2:?}")] - WikitextSyntax(usize, usize, Vec<crate::token::TokenKind>), - #[error(transparent)] HtmlError(#[from] HtmlError), } @@ -46,6 +46,6 @@ pub enum RikiError { impl RikiError { pub fn wikitext_syntax(line: usize, col: usize, tokens: &[crate::token::TokenKind]) -> Self { let tokens = tokens.to_vec(); - Self::WikitextSyntax(line, col, tokens) + crate::parser::ParserError::WikitextSyntax(line, col, tokens).into() } } diff --git a/src/parser.rs b/src/parser.rs index 81eda42..e13363e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -5,6 +5,12 @@ use line_col::LineColLookup; use log::{debug, trace}; use std::collections::HashMap; +#[derive(Debug, thiserror::Error)] +pub enum ParserError { + #[error("failed to parse wikitext, line {0}, column {1}: {2:?}")] + WikitextSyntax(usize, usize, Vec<crate::token::TokenKind>), +} + #[derive(Debug)] pub struct WikitextParser { tokens: Vec<TokenKind>, |