Skip to main content

Module clean_format

Module clean_format 

Source
Expand description

Clean, human-readable rendering of backend errors for developers.

Renders an error and its cause chain as sectioned plain text (never JSON): per error, its type, message, raise location and an our-code-only stack. Third-party causes are shown message-only and tagged (external). A one-line breadcrumb of the active tracing spans is appended.

Example output:

ChatbotError · StreamingError: Stream ended unexpectedly: rate limit for gpt-5.5
  at chatbot/src/azure_chatbot.rs:824  send_chat_request_and_parse_stream
     server/src/controllers/chatbot.rs:120  send_message
     ⋯ 12 framework frames hidden ⋯

caused by:
  1. ModelError · Database: connection pool timed out
     at models/src/chatbot/conversations.rs:45  get_conversation
        ⋯ 9 framework frames hidden ⋯
  2. pool timed out while waiting for connection  (external)

spans
  http_request{request_id=aea0…} › send_message{course_id=5d79…}

§Design

The four error types live in crates that depend on base, so base cannot name them. They expose their data through the object-safe ErrorTrace trait (blanket-implemented for every BackendError); each type’s generated Debug/clean_string passes a crate-local downcast resolver (see crate::impl_clean_debug). A cause chain only contains error types below a given error in the dependency graph, so a per-crate resolver covers every reachable cause without a runtime registry.

Re-exports§

pub use color::ColorChoice;

Modules§

color
Color handling for the clean error formatter.
frames
Extract, classify and render backtrace frames for the clean error formatter.
spans
Render the tracing span trace as a compact breadcrumb.

Constants§

MAX_CHAIN 🔒
Bound on cause-chain length, guarding against cycles.

Traits§

ErrorTrace
Object-safe view over an error, letting base render types defined in dependent crates.

Functions§

header_line 🔒
render
Render head and its whole cause chain in the clean developer format.
write_cause_node 🔒
write_node 🔒
write_stack 🔒

Type Aliases§

Resolver
A resolver turns a type-erased cause into an ErrorTrace if it is one of our errors. Generated per crate by crate::impl_clean_debug.