aboutsummaryrefslogtreecommitdiff
path: root/apps/cassiopeia/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/cassiopeia/src/error.rs')
-rw-r--r--apps/cassiopeia/src/error.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/cassiopeia/src/error.rs b/apps/cassiopeia/src/error.rs
index 31f5414c4f86..24bbb4965494 100644
--- a/apps/cassiopeia/src/error.rs
+++ b/apps/cassiopeia/src/error.rs
@@ -1,7 +1,7 @@
//! A set of error types for cassiopeia
-use std::error::Error;
use std::fmt::{self, Display, Formatter};
+use std::{error::Error, io};
/// User errors that can occur when using cassiopeia
///
@@ -45,6 +45,14 @@ pub enum ParseError {
/// This error means that the structure of the parsed file is
/// wrong, with an invalid sequence of events expressed
User(UserError),
+ /// The requested file did not exist
+ NoSuchFile,
+ /// The file could not be read
+ BadPermissions,
+ /// The file could not be written to
+ FileNotWritable,
+ /// Other file related errors
+ FileUnknown(String),
/// An invalid keyword was found
BadKeyword { line: usize, tokn: String },
/// A bad timestamp was found
@@ -70,3 +78,14 @@ impl From<UserError> for ParseError {
ParseError::User(user)
}
}
+
+impl From<io::Error> for ParseError {
+ fn from(e: io::Error) -> Self {
+ use io::ErrorKind::*;
+ match e.kind() {
+ NotFound => Self::NoSuchFile,
+ PermissionDenied => Self::BadPermissions,
+ _ => Self::FileUnknown(format!("{}", e)),
+ }
+ }
+}