summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-10-05 13:20:46 +0200
committerLaurenz <laurmaedje@gmail.com>2022-10-05 13:20:46 +0200
commit0a0feb75fe1006bdf6ca816a79d3af402da0bfd5 (patch)
treec05a07bb89be98181fd1864c4c48de58df86ea92
parentfd8160f3749135400b3d2c59bf6bfb729c081f16 (diff)
Add `NotSource` variant to `FileError`
-rw-r--r--src/diag.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/diag.rs b/src/diag.rs
index f13c41e1..ed4d4756 100644
--- a/src/diag.rs
+++ b/src/diag.rs
@@ -184,10 +184,12 @@ pub type FileResult<T> = Result<T, FileError>;
pub enum FileError {
/// A file was not found at this path.
NotFound(PathBuf),
- /// A directory was found, but a file was expected.
- IsDirectory,
/// A file could not be accessed.
AccessDenied,
+ /// A directory was found, but a file was expected.
+ IsDirectory,
+ /// The file is not a Typst source file, but should have been.
+ NotSource,
/// The file was not valid UTF-8, but should have been.
InvalidUtf8,
/// Another error.
@@ -218,8 +220,9 @@ impl Display for FileError {
Self::NotFound(path) => {
write!(f, "file not found (searched at {})", path.display())
}
- Self::IsDirectory => f.pad("failed to load file (is a directory)"),
Self::AccessDenied => f.pad("failed to load file (access denied)"),
+ Self::IsDirectory => f.pad("failed to load file (is a directory)"),
+ Self::NotSource => f.pad("not a typst source file"),
Self::InvalidUtf8 => f.pad("file is not valid utf-8"),
Self::Other => f.pad("failed to load file"),
}