Skip to content

Commit b05d811

Browse files
authored
doc: Add documentation for error handling (#18762)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> Added a top-level documentation in the error module, to explain the error types and existing macros. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent e557d0a commit b05d811

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

datafusion/common/src/error.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,25 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
//! DataFusion error types
18+
//! # Error Handling in DataFusion
19+
//!
20+
//! In DataFusion, there are two types of errors that can be raised:
21+
//!
22+
//! 1. Expected errors – These indicate invalid operations performed by the caller,
23+
//! such as attempting to open a non-existent file. Different categories exist to
24+
//! distinguish their sources (e.g., [`DataFusionError::ArrowError`],
25+
//! [`DataFusionError::IoError`], etc.).
26+
//!
27+
//! 2. Unexpected errors – Represented by [`DataFusionError::Internal`], these
28+
//! indicate that an internal invariant has been broken, suggesting a potential
29+
//! bug in the system.
30+
//!
31+
//! There are several convenient macros for throwing errors. For example, use
32+
//! `exec_err!` for expected errors.
33+
//! For invariant checks, you can use `assert_or_internal_err!`,
34+
//! `assert_eq_or_internal_err!`, `assert_ne_or_internal_err!` for easier assertions.
35+
//! On the performance-critical path, use `debug_assert!` instead to reduce overhead.
36+
1937
#[cfg(feature = "backtrace")]
2038
use std::backtrace::{Backtrace, BacktraceStatus};
2139

0 commit comments

Comments
 (0)