-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jsondocck: Parse, don't validate commands.
- Loading branch information
1 parent
15b663e
commit a204534
Showing
3 changed files
with
181 additions
and
262 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,29 +1,7 @@ | ||
use std::error::Error; | ||
use std::fmt; | ||
|
||
use crate::Command; | ||
|
||
#[derive(Debug)] | ||
pub enum CkError { | ||
/// A check failed. File didn't exist or failed to match the command | ||
FailedCheck(String, Command), | ||
/// An error triggered by some other error | ||
Induced(Box<dyn Error>), | ||
} | ||
|
||
impl fmt::Display for CkError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
CkError::FailedCheck(msg, cmd) => { | ||
write!(f, "Failed check: {} on line {}", msg, cmd.lineno) | ||
} | ||
CkError::Induced(err) => write!(f, "Check failed: {}", err), | ||
} | ||
} | ||
} | ||
|
||
impl<T: Error + 'static> From<T> for CkError { | ||
fn from(err: T) -> CkError { | ||
CkError::Induced(Box::new(err)) | ||
} | ||
pub struct CkError { | ||
pub message: String, | ||
pub command: Command, | ||
} |
Oops, something went wrong.