-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Patrick Uiterwijk <[email protected]>
- Loading branch information
1 parent
314dc7d
commit caaa774
Showing
8 changed files
with
368 additions
and
565 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
pub(crate) enum Error { | ||
TPM(tss_esapi::Error), | ||
Hyper(hyper::Error), | ||
InvalidRequest, | ||
Ini(ini::ini::Error), | ||
Configuration(String), | ||
Serde(serde_json::Error), | ||
Permission, | ||
IO(std::io::Error), | ||
Utf8(std::string::FromUtf8Error), | ||
SecureMount, | ||
TPMInUse, | ||
Execution(Option<i32>, String), | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
// TODO | ||
write!(f, "todo: {:?}", self) | ||
} | ||
} | ||
|
||
impl std::error::Error for Error { | ||
fn description(&self) -> &str { | ||
"Keylime Error" | ||
} | ||
} | ||
|
||
impl From<tss_esapi::Error> for Error { | ||
fn from(err: tss_esapi::Error) -> Self { | ||
Error::TPM(err) | ||
} | ||
} | ||
|
||
impl From<hyper::Error> for Error { | ||
fn from(err: hyper::Error) -> Self { | ||
Error::Hyper(err) | ||
} | ||
} | ||
|
||
impl From<ini::ini::Error> for Error { | ||
fn from(err: ini::ini::Error) -> Self { | ||
Error::Ini(err) | ||
} | ||
} | ||
|
||
impl From<serde_json::Error> for Error { | ||
fn from(err: serde_json::Error) -> Self { | ||
Error::Serde(err) | ||
} | ||
} | ||
|
||
impl From<std::io::Error> for Error { | ||
fn from(err: std::io::Error) -> Self { | ||
Error::IO(err) | ||
} | ||
} | ||
|
||
impl From<std::string::FromUtf8Error> for Error { | ||
fn from(err: std::string::FromUtf8Error) -> Self { | ||
Error::Utf8(err) | ||
} | ||
} | ||
|
||
pub(crate) type Result<T> = std::result::Result<T, Error>; |
Oops, something went wrong.