Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Report / Exposure Boundary

This document describes the responsibility boundary between DiagnosticReport and ErrorProtocolSnapshot.

Current State

category and code have been removed from DiagnosticReport. Identity data now lives exclusively in ErrorProtocolSnapshot.identity. All exposure bridge methods on DiagnosticReport (exposure_identity, http_status, visibility, default_hints, decision, exposure, to_exposure_json) have been deleted.

StructError<T>::report() only requires DomainReason, not ErrorIdentityProvider.

1. Object Roles

ObjectResponsibility
StructError<R>Runtime propagation, source chain, context attachment
DiagnosticReportHuman diagnostic view, redaction, text rendering
ErrorProtocolSnapshotIdentity + exposure decision + report, user debug, protocol JSON projection

Human diagnostics:

#![allow(unused)]
fn main() {
let report = err.report();
let text = report.render();
}

Protocol/projection:

#![allow(unused)]
fn main() {
let proto = err.exposure(&policy);
let debug = proto.render_user_debug();
let http = proto.to_http_error_json()?;
}

3. Principles

  • DiagnosticReport stays a diagnostic object.
  • ErrorProtocolSnapshot is the sole exposure/projection closure.
  • StructError routes runtime errors into either report or protocol layer.

In short:

  • Need text diagnostics → report()
  • Need exposure / JSON projection → exposure(…)

4. From DiagnosticReport to Protocol

If the caller starts from an existing DiagnosticReport (not StructError):

#![allow(unused)]
fn main() {
let proto = ErrorProtocolSnapshot::from_report_skeleton(report, identity, &policy);
}

But if full projection data (root metadata, source frames, path) is needed, prefer StructError::exposure(...).

5. Summary

The current design keeps DiagnosticReport focused on diagnostics while ErrorProtocolSnapshot handles all exposure and projection concerns. The two paths are independent and should not be mixed.