pub fn reify_error(
registry: ComposedRegistry<'_>,
error_code: &str,
deser: &mut dyn ShapeDeserializer,
) -> Option<Box<dyn Error + Send + Sync>>Expand description
Reify an error response body into a boxed dyn std::error::Error, scoped to
an operation and then widened to the service.
Given a registry composed as operation_errors.or(&service_errors), a wire
error_code, and a ShapeDeserializer positioned at the error body (such
as the one returned by a protocol’s deserialize_error_response), this looks
the code up — the operation’s own errors first, then the service-wide set —
and runs the matched entry’s ErrorDeserializeFn. The result is the typed
error boxed as a dyn std::error::Error, ready to be attached as the
source of an unhandled error.
It is the registry-backed fallback for the schema-serde error path, meant to
run only after an operation’s modeled-error match misses, to recover
structure from an error the operation does not model but the service (or an
extension package) does. Deserialization failures are swallowed (returning
None) so a malformed or unexpected body can never change how an operation
fails relative to the plain generic-error path.
HTTP response bindings on a reified error are populated, provided the
caller passes a deserializer obtained from a protocol that owns them. A REST
protocol’s deserialize_error_response returns a composite that reads
@httpHeader, @httpPrefixHeaders, and @httpResponseCode members from the
response and delegates the remaining members to the body codec, so the
entry’s ErrorDeserializeFn — which is the shape’s protocol-agnostic
member consumer — receives values from both sources. Body-only protocols
return a body-only deserializer and those members stay absent, which is the
correct behavior for them.
Returns None if error_code matches no registered shape, if the matched
entry carries no ErrorDeserializeFn (i.e. it was not registered as an
@error shape), or if deserialization of the matched shape fails.