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
52 changes: 26 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions crates/nvisy-server/src/handler/error/engine_error.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Redaction-engine error to HTTP error conversion.
//!
//! Maps `elide_pipeline::Error` onto an HTTP error by its kind: a
//! `MalformedInput` is a bad document the caller supplied (a client error),
//! while every other kind — including `CapabilityUnavailable` (a codec/renderer
//! the build does not ship) — is a server-side processing fault. The engine's
//! own message travels along as context.
//! Maps `elide_pipeline::Error` onto an HTTP error by its kind. Two kinds are
//! caller errors: `MalformedInput` is a bad document the caller supplied, and
//! `Configuration` is an incoherent request or policy set (e.g. policies that can
//! detect but never redact, or a reviewer override naming an off-pipeline
//! policy). Every other kind — including `CapabilityUnavailable` (a codec or
//! renderer the build does not ship) — is a server-side processing fault. The
//! engine's own message travels along as context.

use elide_pipeline::ErrorKind as EngineErrorKind;
use elide_pipeline::entity::EditError;
Expand All @@ -17,6 +19,9 @@ impl<'a> From<elide_pipeline::Error> for HttpError<'a> {
EngineErrorKind::MalformedInput => ErrorKind::BadRequest
.with_message("Document could not be processed")
.with_context(error.to_string()),
EngineErrorKind::Configuration => ErrorKind::BadRequest
.with_message("The pipeline's policies cannot process this request")
.with_context(error.to_string()),
_ => ErrorKind::InternalServerError
.with_message("Redaction engine failed")
.with_context(error.to_string()),
Expand Down