pub struct SparkError {
pub kind: SparkErrorKind,
pub error_class: String,
pub params: BTreeMap<String, String>,
pub message: String,
pub sql_state: Option<String>,
pub contexts: Vec<QueryContext>,
pub server_stacktrace: Option<String>,
pub grpc_code: Option<i32>,
pub grpc_details: Option<Vec<u8>>,
}Expand description
Re-exported so fallible APIs (e.g. the #[spark_wasm_udf]-generated UDF
constructors) can name the client’s Result/error types.
A structured error carrying a PySpark error class and its message parameters.
Fields§
§kind: SparkErrorKindWhich Python exception type to raise at the PyO3 boundary.
error_class: StringPySpark error class (e.g. “INVALID_CONNECT_URL”), or empty for plain messages.
params: BTreeMap<String, String>Message parameters keyed by name, as in messageParameters.
message: StringA pre-rendered message, used when no error class applies.
sql_state: Option<String>SQL state code, if known (from the error-conditions registry).
contexts: Vec<QueryContext>Query contexts where the error occurred.
server_stacktrace: Option<String>Server-side stack trace, if available.
grpc_code: Option<i32>Raw gRPC status code, if this error originated from a gRPC Status.
grpc_details: Option<Vec<u8>>Raw grpc-status-details-bin (a serialized google.rpc.Status), if present.
Lets the PyO3 layer reconstruct the exact typed pyspark exception.
Implementations§
Source§impl SparkError
impl SparkError
Sourcepub fn value(error_class: &str, params: &[(&str, &str)]) -> SparkError
pub fn value(error_class: &str, params: &[(&str, &str)]) -> SparkError
Create a ValueError-kind error with an error class and parameters.
Sourcepub fn connect_msg(message: impl Into<String>) -> SparkError
pub fn connect_msg(message: impl Into<String>) -> SparkError
Create a Connect-kind error with a plain message (no error class).
Sourcepub fn value_msg(message: impl Into<String>) -> SparkError
pub fn value_msg(message: impl Into<String>) -> SparkError
Create a ValueError-kind error with a plain message (no error class).
For invalid client-side configuration (e.g. a malformed connection string)
that has no registered error class. Surfaces as PySparkValueError on the
Python side, matching how the reference client reports connection-string
problems, rather than the generic runtime kind.
Sourcepub fn classed(
kind: SparkErrorKind,
error_class: &str,
params: &[(&str, &str)],
) -> SparkError
pub fn classed( kind: SparkErrorKind, error_class: &str, params: &[(&str, &str)], ) -> SparkError
Create an error of a specific kind with an error class and parameters.
Sourcepub fn message(&self) -> String
pub fn message(&self) -> String
Get the rendered message for this error, performing template substitution.
If an error_class is set, looks up the message template in error-conditions.json,
substitutes <param_name> placeholders with values from params, and returns
[ERROR_CLASS] rendered_message. Otherwise, returns the pre-set message.
Mirrors PySparkException.getMessage() from pyspark/errors/exceptions/base.py.
Sourcepub fn from_grpc_status(status: Status) -> SparkError
pub fn from_grpc_status(status: Status) -> SparkError
Convert a gRPC Status to a SparkError, extracting error class and parameters from metadata.
Mirrors convert_exception from pyspark.errors.exceptions.connect.
Sourcepub fn get_condition(&self) -> Option<String>
pub fn get_condition(&self) -> Option<String>
Get the error condition (error class).
Mirrors PySparkException.getCondition() from PySpark.
Sourcepub fn get_error_class(&self) -> Option<String>
pub fn get_error_class(&self) -> Option<String>
Get the error class (deprecated, use get_condition instead).
Mirrors PySparkException.getErrorClass() from PySpark (deprecated).
Sourcepub fn get_message_parameters(&self) -> Option<BTreeMap<String, String>>
pub fn get_message_parameters(&self) -> Option<BTreeMap<String, String>>
Get the message parameters.
Mirrors PySparkException.getMessageParameters() from PySpark.
Sourcepub fn get_sql_state(&self) -> Option<String>
pub fn get_sql_state(&self) -> Option<String>
Get the SQL state code, if known.
Mirrors PySparkException.getSqlState() from PySpark.
Sourcepub fn get_message(&self) -> String
pub fn get_message(&self) -> String
Get the rendered error message.
Mirrors PySparkException.getMessage() from PySpark.
Sourcepub fn get_query_context(&self) -> Vec<QueryContext>
pub fn get_query_context(&self) -> Vec<QueryContext>
Get the query contexts where this error occurred.
Mirrors PySparkException.getQueryContext() from PySpark.
Sourcepub fn get_stacktrace(&self) -> Option<String>
pub fn get_stacktrace(&self) -> Option<String>
Get the server-side stack trace, if available.
Sourcepub fn grpc_code(&self) -> Option<i32>
pub fn grpc_code(&self) -> Option<i32>
Raw gRPC status code, if this error came from a gRPC Status.
Sourcepub fn grpc_details(&self) -> Option<&[u8]>
pub fn grpc_details(&self) -> Option<&[u8]>
Raw grpc-status-details-bin bytes (serialized google.rpc.Status), if present.
Trait Implementations§
Source§impl Clone for SparkError
impl Clone for SparkError
Source§fn clone(&self) -> SparkError
fn clone(&self) -> SparkError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SparkError
impl Debug for SparkError
Source§impl Display for SparkError
impl Display for SparkError
Source§impl Error for SparkError
impl Error for SparkError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for SparkError
impl RefUnwindSafe for SparkError
impl Send for SparkError
impl Sync for SparkError
impl Unpin for SparkError
impl UnsafeUnpin for SparkError
impl UnwindSafe for SparkError
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request