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

Feature Flags

masterror keeps the default build lean: only std is enabled out of the box. Everything else — web transports, telemetry, library integrations — is opt-in. This page is the complete reference for every flag declared in Cargo.toml.

[dependencies]
masterror = { version = "0.28", default-features = false }
# or with features:
# masterror = { version = "0.28", features = [
#   "std", "axum", "actix", "openapi",
#   "serde_json", "tracing", "metrics", "backtrace",
#   "colored", "sqlx", "sqlx-migrate", "reqwest",
#   "redis", "validator", "config", "tokio",
#   "multipart", "teloxide", "init-data", "tonic",
#   "frontend", "turnkey", "benchmarks"
# ] }

Core

FlagWhat it enablesExtra deps
std (default)Standard library support; required by all runtime integrations. Disable for no_std (see No-Std)

Web transports

FlagWhat it enablesExtra deps
axumIntoResponse for AppError and ProblemJson with RFC 7807 JSON bodies; AppErrorKind::status_code()axum (json, multipart), serde_json
actixActix Web ResponseError for AppError and Responder for ProblemJsonactix-web
multipartMaps axum::extract::multipart::MultipartErrorBadRequest (implies axum)via axum
openapiutoipa::ToSchema for ErrorResponse and AppCode so error payloads appear in OpenAPI specsutoipa
serde_jsonStructured JSON details on AppError/ErrorResponse/ProblemJson; FieldValue::Json and field::jsonserde_json
tonicConversion of errors into tonic::Status with sanitized metadata; exports StatusConversionErrortonic

Telemetry and observability

FlagWhat it enablesExtra deps
tracingStructured tracing events emitted when errors are constructedtracing, log, log-mdc
metricsIncrements an error_total{code,category} counter for each AppErrormetrics
backtraceLazy std::backtrace::Backtrace capture (honours RUST_BACKTRACE), with_backtrace() builder
coloredColored multi-line terminal output with automatic TTY detection; richer Display for AppErrorowo-colors

Async and IO integrations

Each integration flag adds a From<...> for AppError conversion that classifies the library error into the taxonomy:

FlagConversionExtra deps
sqlxsqlx_core::ErrorNotFound / Database (lean sqlx-core, no drivers or TLS)sqlx-core
sqlx-migratesqlx::migrate::MigrateErrorDatabase (full sqlx with migrate feature only)sqlx
redisredis::RedisErrorCacheredis
reqwestreqwest::ErrorTimeout / Network / ExternalApireqwest
tokiotokio::time::error::ElapsedTimeouttokio (time)
validatorvalidator::ValidationErrorsValidationvalidator
configconfig::ConfigErrorConfigconfig

sqlx and sqlx-migrate are split deliberately: error classification only needs sqlx-core, while migration error mapping pulls the full sqlx crate.

Messaging and bots

FlagConversionExtra deps
teloxideteloxide_core::RequestErrorRateLimited / Network / ExternalApi / Deserialization / Internalteloxide-core
init-datainit_data_rs::InitDataErrorTelegramAuth (Telegram Mini Apps init-data validation)init-data-rs

Front-end and domain

FlagWhat it enablesExtra deps
frontendfrontend module: convert errors to wasm_bindgen::JsValue and emit console.error logs in WASM/browser contextswasm-bindgen, js-sys, serde-wasm-bindgen
turnkeyturnkey module: TurnkeyErrorKind, TurnkeyError, classify_turnkey_error and conversions into AppError
benchmarksCriterion benchmark suite and CI baseline tooling (local profiling only)

Baseline conversions (always available)

Without any feature flag, AppError already converts from:

SourceTarget kind
std::io::ErrorInternal
StringBadRequest

Recipes

REST API on Axum with problem+json, OpenAPI docs and tracing:

masterror = { version = "0.28", features = ["axum", "openapi", "serde_json", "tracing"] }

Database service with sqlx, migrations and metrics:

masterror = { version = "0.28", features = ["sqlx", "sqlx-migrate", "metrics", "tracing"] }

gRPC service:

masterror = { version = "0.28", features = ["tonic", "tracing", "backtrace"] }

Telegram bot with Mini App auth:

masterror = { version = "0.28", features = ["teloxide", "init-data", "reqwest", "tokio"] }

WASM front-end:

masterror = { version = "0.28", features = ["frontend", "serde_json"] }

no_std embedded or library target:

masterror = { version = "0.28", default-features = false }

Notes

  • All integration flags imply std except sqlx and sqlx-migrate, which stay std-independent at the flag level.
  • axum and actix pull serde_json transitively because their response bodies are JSON.
  • Feature flags never change the wire contract of ErrorResponse/ProblemJson fields that are already enabled — they only add capabilities (e.g. serde_json upgrades details from plain text to structured JSON) or trait implementations.

See also: Getting Started · Web Frameworks · Integrations · Observability · No-Std