Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/tools/jsondocck/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ impl Cache {
}
}

pub fn value(&self) -> &Value {
&self.value
// FIXME: Make this failible, so jsonpath syntax error has line number.
pub fn select(&self, path: &str) -> Vec<&Value> {
jsonpath_lib::select(&self.value, path).unwrap()
}
}
28 changes: 3 additions & 25 deletions src/tools/jsondocck/src/error.rs
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,
}
Loading
Loading