Skip to main content

rocketmq_error/
lib.rs

1// Copyright 2023 The RocketMQ Rust Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![deny(missing_docs)]
16
17//! # RocketMQ Error Handling
18//!
19//! This crate provides the canonical catalog, opaque [`Error`] envelope,
20//! typed context, safe views, and boundary-neutral policy used by RocketMQ
21//! components.
22//!
23//! Catalog descriptors are the sole owners of stable identity and policy.
24//! Error instances retain one direct typed source and record the first caller
25//! that promotes a failure into the canonical envelope. Formatting and safe
26//! views never render source text, caller paths, or backtrace frames.
27//!
28//! ```rust
29//! use std::io;
30//! use rocketmq_error::{Error, Result, RUNTIME_IO_FAILED};
31//!
32//! fn read_metadata() -> Result<()> {
33//!     Err(Error::caused_by(
34//!         &RUNTIME_IO_FAILED,
35//!         io::Error::other("metadata read failed"),
36//!     ))
37//! }
38//!
39//! let error = read_metadata().expect_err("example failure");
40//! assert_eq!(error.code().as_str(), "runtime.io.failed");
41//! ```
42//!
43mod boundary;
44mod catalog;
45mod cli;
46mod context;
47mod descriptor;
48mod error;
49mod field;
50mod filter_error;
51mod projection;
52mod recovery;
53mod view;
54
55pub use boundary::CliExitCode;
56pub use boundary::CliSpec;
57pub use boundary::GrpcPayloadCode;
58pub use boundary::GrpcSpec;
59pub use boundary::GrpcStatusCode;
60pub use boundary::HttpSpec;
61pub use boundary::HttpStatusCode;
62pub use boundary::RemotingResponseCode;
63pub use boundary::RemotingSpec;
64pub use catalog::*;
65pub use cli::CliErrorView;
66pub use cli::CliOutput;
67pub use cli::CliVerbosity;
68pub use context::ErrorContext;
69pub use context::ErrorContextField;
70pub use context::FieldValueRef;
71pub use context::Sensitive;
72pub use context::REDACTED;
73pub use descriptor::BacktracePolicy;
74pub use descriptor::ComponentId;
75pub use descriptor::ErrorClass;
76pub use descriptor::ErrorCode;
77pub use descriptor::ErrorDescriptor;
78pub use descriptor::ErrorSeverity;
79pub use descriptor::Exposure;
80pub use descriptor::FaultAttribution;
81pub use error::Error;
82pub use error::Result;
83pub use error::SharedError;
84pub use field::fields;
85pub use field::BoolField;
86pub use field::ContextVisibility;
87pub use field::FieldKey;
88pub use field::FieldSchema;
89pub use field::FieldValueKind;
90pub use field::I64Field;
91pub use field::SecretPresenceField;
92pub use field::TextField;
93pub use field::U64Field;
94pub use filter_error::FilterCompileError;
95pub use filter_error::FilterCompileErrorKind;
96pub use filter_error::FilterCompileSource;
97pub use filter_error::FilterCompileStage;
98pub use projection::ProjectionSpec;
99pub use recovery::CanonicalCondition;
100pub use recovery::RecoveryHint;
101pub use view::DiagnosticFields;
102pub use view::DiagnosticView;
103pub use view::PublicErrorView;
104pub use view::PublicFields;
105pub use view::ViewContextViolation;
106pub use view::ViewFieldRef;
107pub use view::ViewValueRef;