Skip to main content

SparkError

Struct SparkError 

Source
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: SparkErrorKind

Which Python exception type to raise at the PyO3 boundary.

§error_class: String

PySpark 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: String

A 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

Source

pub fn value(error_class: &str, params: &[(&str, &str)]) -> SparkError

Create a ValueError-kind error with an error class and parameters.

Source

pub fn connect_msg(message: impl Into<String>) -> SparkError

Create a Connect-kind error with a plain message (no error class).

Source

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.

Source

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.

Source

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.

Source

pub fn sql_state(&self) -> Option<String>

Get the SQL state code for this error, if known.

Source

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.

Source

pub fn get_condition(&self) -> Option<String>

Get the error condition (error class).

Mirrors PySparkException.getCondition() from PySpark.

Source

pub fn get_error_class(&self) -> Option<String>

Get the error class (deprecated, use get_condition instead).

Mirrors PySparkException.getErrorClass() from PySpark (deprecated).

Source

pub fn get_message_parameters(&self) -> Option<BTreeMap<String, String>>

Get the message parameters.

Mirrors PySparkException.getMessageParameters() from PySpark.

Source

pub fn get_sql_state(&self) -> Option<String>

Get the SQL state code, if known.

Mirrors PySparkException.getSqlState() from PySpark.

Source

pub fn get_message(&self) -> String

Get the rendered error message.

Mirrors PySparkException.getMessage() from PySpark.

Source

pub fn get_query_context(&self) -> Vec<QueryContext>

Get the query contexts where this error occurred.

Mirrors PySparkException.getQueryContext() from PySpark.

Source

pub fn get_stacktrace(&self) -> Option<String>

Get the server-side stack trace, if available.

Source

pub fn grpc_code(&self) -> Option<i32>

Raw gRPC status code, if this error came from a gRPC Status.

Source

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

Source§

fn clone(&self) -> SparkError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SparkError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for SparkError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for SparkError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more