pub enum CaptureFailure {
Shadowed {
environment: Option<PathBuf>,
},
InvalidPath {
reason: String,
},
BodyNotJson {
reason: String,
content_type: Option<String>,
},
NoMatch,
Ambiguous {
count: usize,
sample: Vec<String>,
},
NotAScalar {
kind: &'static str,
},
HeaderNotFound {
header: String,
present: Vec<String>,
},
}Expand description
Why one entry of a capture block did not produce a value.
Typed rather than a bare string so a front-end can branch on it — and so
the granularity the assertion JSON paths already draw (“not a valid JSON
path” is a broken file, “the body is not JSON” is a fact about this
response, “matched nothing” is a fact about the pair) survives into
anything reading a run rather than being recoverable only by matching on
prose. Display renders the wording, in core, so every
front-end says the same thing about the same failure.
Variants§
Shadowed
The name is already defined by the active environment file. See the note on this variant’s message for why that is rejected rather than resolved in either direction.
Fields
InvalidPath
The path is not a JSON path at all.
BodyNotJson
The response body did not parse as JSON, so there was nothing to query.
Fields
NoMatch
The path is valid and the body is JSON, and the path selected nothing.
Ambiguous
The source selected more than one value, so there is no single value
to bind the name to. Raised for a JSON path matching several values,
and — the same philosophy applied to a second source — for a header
capture whose name repeats in the response (Set-Cookie is the
common case). See the module docs for why a capture does not resolve
a repeated header by taking the first or last value, the way an
assertion checking the same header does.
NotAScalar
The path selected exactly one value and that value has no text form a
{{name}} could be replaced with: null, an array or an object.
HeaderNotFound
A header: capture named a header the response does not carry.
Trait Implementations§
Source§impl Clone for CaptureFailure
impl Clone for CaptureFailure
Source§fn clone(&self) -> CaptureFailure
fn clone(&self) -> CaptureFailure
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CaptureFailure
impl Debug for CaptureFailure
Source§impl Display for CaptureFailure
impl Display for CaptureFailure
impl Eq for CaptureFailure
Source§impl PartialEq for CaptureFailure
impl PartialEq for CaptureFailure
impl StructuralPartialEq for CaptureFailure
Auto Trait Implementations§
impl Freeze for CaptureFailure
impl RefUnwindSafe for CaptureFailure
impl Send for CaptureFailure
impl Sync for CaptureFailure
impl Unpin for CaptureFailure
impl UnsafeUnpin for CaptureFailure
impl UnwindSafe for CaptureFailure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.