Expand description
Error and result types for the python-ast crate.
This module re-exports anyhow_tracing::Error / anyhow_tracing::Result as the
crate-wide Error / Result types so that errors carry structured fields
(location, feature, expected, found, …) instead of pre-formatted Strings, which
allows tracing/logging consumers — and downstream code that wants to recover the
typed payload via anyhow_tracing::Error::downcast_ref — to inspect the original
data without having to re-parse a stringified message.
The concrete error kinds (e.g. ParseError, UnsupportedFeature,
BinOpNotYetImplemented) are exposed as small thiserror-derived structs that
implement std::error::Error. They are wrapped into anyhow_tracing::Error at
the construction site (see the helper constructors on this module’s Error-shim
re-exports below: parsing_error, codegen_error, unsupported_feature,
type_error, syntax_error). The wrapping carries named fields so structured
tracing subscribers see fields rather than a stringified blob, while downcasts
still recover the typed payload.
Macros§
- anyhow
- Creates an
Errorfrom a format string and arguments, optionally with named fields. - bail
- Returns early with an
Error. - ensure
- Returns early with an
Errorif a condition is not satisfied.
Structs§
- BinOp
NotYet Implemented - A binary operator the transpiler does not yet handle. Carries the original
BinOpAST node so callers can inspect it without having to re-parse a stringified message. - Bool
OpNot YetImplemented - Code
GenError - Code generation failed.
- Compare
NotYet Implemented - Error
- An error type that extends
anyhow::Errorwith named fields. - Expr
NotYet Implemented - Expr
Type NotYet Implemented - Parse
Error - Python parsing failed.
- Source
Location - Location information for error reporting.
- Statement
NotYet Implemented - Syntax
Error - The Python source contained invalid syntax.
- Type
Error - A type mismatch was detected during code generation.
- Unary
OpNot YetImplemented - Unknown
Type - Unsupported
Feature - A Python feature is not yet implemented in the transpiler.
Traits§
- Context
- Extension trait for adding context and fields to errors.
- IntoErr
- Converts foreign error results into the crate’s structured
Resulttype.
Functions§
- codegen_
error - Create a code generation error with location and helpful guidance.
- err_
from - Convert any
std::error::Errorinto the crate-wideError. - error_
to_ pyerr - Convert a crate
Errorinto aPyErrsuitable for returning across the PyO3 boundary. Performs structural downcasting so e.g.SyntaxErrorbecomesPySyntaxErrorandUnsupportedFeaturebecomesPyNotImplementedError. - format_
error_ chain - Render an error and its full
source()chain as a single string, so the complete causal context survives type-erasedBox<dyn Error>boundaries (whoseDisplayonly shows the outermost message). - parsing_
error - Create a parsing error with location and helpful guidance.
- syntax_
error - Create a syntax error with location and helpful guidance.
- type_
error - Create a type error with location and helpful guidance.
- unsupported_
feature - Create an unsupported-feature error with location and helpful guidance.
Type Aliases§
- Result
- A type alias for
Result<T, Error>.