1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum SiteError {
#[error("source directory doesn't exist: {0}")]
SourceDirMissing(PathBuf),
#[error("failed to list files in source directory: {0}")]
WalkDir(PathBuf, #[source] walkdir::Error),
#[error("could not read file: {0}")]
FileRead(PathBuf, #[source] std::io::Error),
#[error("could not write file: {0}")]
FileWrite(PathBuf, #[source] std::io::Error),
#[error("string formatting error: {0}")]
Format(#[source] std::fmt::Error),
#[error("could not convert input text from {0} to UTF-8")]
Utf8(PathBuf, #[source] std::string::FromUtf8Error),
#[error("failed to canonicalize path {0}")]
Canonicalize(PathBuf, #[source] std::io::Error),
#[error("failed to compute relative path for {0} against {1}")]
Relative(PathBuf, PathBuf),
#[error("failed to create {0}")]
CreateFile(PathBuf, #[source] std::io::Error),
#[error("failed to copy {0} to {1}")]
CopyFile(PathBuf, PathBuf, #[source] std::io::Error),
#[error("failed to create directory {0}")]
CreateDir(PathBuf, #[source] std::io::Error),
#[error("unknown directive {0}")]
UnknownDirective(String),
#[error("directive {0} does not allow unnamed arguments")]
UnknownArgsNotAllowed(String),
#[error("directive {0} has more than one unnamed argument")]
TooManyUnnamedArgs(String),
#[error("directive {0} is missing required argument {1}")]
DirectiveMissingArg(String, String),
#[error("directive {0} has unknown argument {1}")]
DirectiveUnknownArg(String, String),
#[error("link to missing page {1} on {0}")]
PageMissing(PathBuf, PathBuf),
#[error("attempt to use definition lists in Markdown: line {0}, column {1}")]
DefinitionList(usize, usize),
#[error("failed to get file metadata: {0}")]
FileMetadata(PathBuf, #[source] std::io::Error),
#[error("failed to get file modification time: {0}")]
FileMtime(PathBuf, #[source] std::io::Error),
#[error("failed to set modification time for file {0}")]
Utimensat(PathBuf, #[source] std::io::Error),
#[error("failed to convert time to Unix time")]
UnixTime(#[source] std::time::SystemTimeError),
#[error("failed to parse Unix timetamp: {0}")]
ParseUnixTimestamp(String, #[source] std::num::ParseIntError),
#[error("faileed to invoked git with subcommand {0} in {1}")]
GitInvoke(String, PathBuf, #[source] std::io::Error),
#[error("git {0} in in {1}:\n{2}")]
GitError(String, PathBuf, String),
#[error("failed to parse date: {0:?}")]
UnknownTimestamp(String),
#[error("failed to process page {0}")]
PageProblem(PathBuf, #[source] Box<Self>),
#[error(transparent)]
PageSpec(#[from] crate::pagespec::PageSpecError),
#[error("failed to parse wikitext, line {0}, column {1}: {2:?}")]
WikitextSyntax(usize, usize, Vec<crate::token::TokenKind>),
}
impl SiteError {
pub fn wikitext_syntax(line: usize, col: usize, tokens: &[crate::token::TokenKind]) -> Self {
let tokens = tokens.to_vec();
Self::WikitextSyntax(line, col, tokens)
}
}
|