summaryrefslogtreecommitdiff
path: root/src/error.rs
blob: aee82526058344335925ce653ebc1dc5d4b87cd6 (plain)
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
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} 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: {0:?}")]
    DefinitionList(String),

    #[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),
}