#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum ParseError {
#[error("a `with.fhir` expression is never empty")]
Empty,
#[error(
"`${name}` at byte {at} is no FHIR-side variable; FHIRconnect defines `$resource` and `$fhirRoot`"
)]
UnknownVariable {
name: String,
at: usize,
},
#[error("`{name}(` at byte {at} is no path function of this model")]
UnknownFunction {
name: String,
at: usize,
},
#[error("expected {expected} at byte {at}, found `{found}`")]
Expected {
expected: &'static str,
found: String,
at: usize,
},
#[error("the string literal opened at byte {at} never closes")]
UnterminatedString {
at: usize,
},
#[error("the call to `{name}` opened at byte {at} never closes")]
UnterminatedCall {
name: String,
at: usize,
},
#[error("`\\{escape}` at byte {at} is no FHIRPath string escape")]
InvalidEscape {
escape: char,
at: usize,
},
#[error("the index `{text}` at byte {at} is no array position")]
Index {
text: String,
at: usize,
},
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum AnchorError {
#[error("the anchor `{anchor}` is not rooted at `$resource`")]
RelativeAnchor {
anchor: String,
},
#[error(
"`{expression}` steps {hops} parents above the anchor `{anchor}`, which is above `$resource`"
)]
AboveResource {
expression: String,
anchor: String,
hops: usize,
},
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum ResolveError {
#[error("`{expression}` must be bound to an anchor before it resolves")]
NotAnchored {
expression: String,
},
#[error("`{name}` is no resource type of this FHIR version")]
UnknownResource {
name: String,
},
#[error("`{owner}` defines no element `{name}`")]
UnknownElement {
owner: String,
name: String,
},
#[error("`{element}` admits {admitted}, not `{requested}`")]
ChoiceType {
element: String,
requested: String,
admitted: String,
},
#[error("`{element}` is `{actual}`, not `{requested}`")]
TypeAssertion {
element: String,
requested: String,
actual: String,
},
#[error(
"`{element}` is a choice element; name its type with `ofType()`, `as()` or the suffixed element name before stepping through it"
)]
UnresolvedChoice {
element: String,
},
#[error("`{element}` holds no element `{name}`")]
NoChildren {
element: String,
name: String,
},
#[error(
"`{element}` holds a resource; name its type with `ofType()` or `as()` before stepping through it"
)]
ResourceContent {
element: String,
},
#[error("`{element}` is no reference, so `resolve()` has nothing to resolve")]
NotAReference {
element: String,
},
#[error("`{element}` does not repeat, so `[{index}]` selects nothing")]
NotRepeating {
element: String,
index: usize,
},
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum ReadError {
#[error("the document carries no `resourceType`")]
NoResourceType,
#[error("the path does not resolve")]
Resolve {
#[source]
source: ResolveError,
},
#[error("`{element}` is {expected} in the JSON representation, and the document holds {found}")]
Shape {
element: String,
expected: &'static str,
found: &'static str,
},
#[error(
"`{element}` carries both `{first}` and `{second}`, and a choice element takes one type"
)]
AmbiguousChoice {
element: String,
first: String,
second: String,
},
#[error(
"`where({expression})` is a FHIRPath predicate, which this path model does not evaluate"
)]
Predicate {
expression: String,
},
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum WriteError {
#[error("`{expression}` is read-only: `{step}` {reason}")]
ReadOnly {
expression: String,
step: String,
reason: &'static str,
},
#[error("the document carries no `resourceType`")]
NoResourceType,
#[error("the path does not resolve")]
Resolve {
#[source]
source: ResolveError,
},
#[error(
"`{element}` is a choice element; the type to write is named by `ofType()`, `as()` or the suffixed element name"
)]
UnresolvedChoice {
element: String,
},
#[error("`{expression}` ends on a reference the engine resolves, which is read-only here")]
ReferenceTarget {
expression: String,
},
#[error("`{element}` repeats, so a write names the occurrence index to set")]
MissingOccurrence {
element: String,
},
#[error("`{element}` does not repeat, so the occurrence index {index} selects nothing")]
NotRepeating {
element: String,
index: usize,
},
#[error("`{element}` holds {length} occurrences, so index {index} would leave a gap")]
OccurrenceGap {
element: String,
index: usize,
length: usize,
},
#[error("`{element}` is {expected} in the JSON representation, and the document holds {found}")]
Shape {
element: String,
expected: &'static str,
found: &'static str,
},
#[error("`{element}` is {expected} in the JSON representation, and the value is {found}")]
TypeNotAdmitted {
element: String,
expected: &'static str,
found: &'static str,
},
#[error("`{element}` takes no `null`; an absent value is an absent element")]
NullValue {
element: String,
},
}