pub enum DisplayMode {
Prod = 0,
Local = 1,
Staging = 2,
}Expand description
Display mode for error output.
Controls the structure and verbosity of error messages based on
the deployment environment. The mode is determined by the
MASTERROR_ENV environment variable or auto-detected based on
build configuration and runtime environment.
§Examples
use masterror::DisplayMode;
let mode = DisplayMode::current();
match mode {
DisplayMode::Prod => println!("Production mode: JSON output"),
DisplayMode::Local => println!("Local mode: Human-readable output"),
DisplayMode::Staging => println!("Staging mode: JSON with context")
}Variants§
Prod = 0
Production mode: lightweight JSON, minimal fields, no sensitive data.
Output includes only: kind, code, message (if not redacted).
Metadata is filtered to exclude sensitive fields.
Source chain and backtrace are excluded.
§Example Output
{"kind":"NotFound","code":"NOT_FOUND","message":"User not found"}Local = 1
Development mode: human-readable, full context.
Output includes: error details, full source chain, complete metadata,
and backtrace (if enabled). Supports colored output when the colored
feature is enabled and output is a TTY.
§Example Output
Error: NotFound
Code: NOT_FOUND
Message: User not found
Caused by: database query failed
Caused by: connection timeout
Context:
user_id: 12345Staging = 2
Staging mode: JSON with additional context.
Output includes: kind, code, message, limited source_chain,
and filtered metadata. No backtrace.
§Example Output
{"kind":"NotFound","code":"NOT_FOUND","message":"User not found","source_chain":["database error"],"metadata":{"user_id":12345}}Implementations§
Source§impl DisplayMode
impl DisplayMode
Sourcepub fn current() -> Self
pub fn current() -> Self
Returns the current display mode based on environment configuration.
The mode is determined by checking (in order):
MASTERROR_ENVenvironment variable (prod,local, orstaging)- Kubernetes environment detection (
KUBERNETES_SERVICE_HOST) - Build configuration (
cfg!(debug_assertions))
The result is cached for performance.
§Examples
use masterror::DisplayMode;
let mode = DisplayMode::current();
assert!(matches!(
mode,
DisplayMode::Prod | DisplayMode::Local | DisplayMode::Staging
));Trait Implementations§
Source§impl Clone for DisplayMode
impl Clone for DisplayMode
Source§fn clone(&self) -> DisplayMode
fn clone(&self) -> DisplayMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more