Skip to main content

Error

Struct Error 

Source
pub struct Error { /* private fields */ }
Expand description

Failure returned by an SDK operation, carrying recovery data and server diagnostics.

§Classify the failure and identify the operation

Error::kind() classifies the failure category, and Error::operation() identifies the SDK operation that failed. For example, a missing table returns ErrorKind::NotFound during both ErrorOperation::Append and ErrorOperation::ReadCatalog. ErrorKind::Incomplete indicates an aggregate operation with unconfirmed input; its attached report describes what happened to the rows.

All async SDK operations return Result<T, Error>, so functions can compose with ? while preserving recovery data:

use scopedb_client::Client;
use scopedb_client::Error;

async fn write(client: &Client) -> Result<(), Error> {
    let stream = client.table("events").append_stream().build()?;
    stream.send(&serde_json::json!({"id": 1})).await?;
    let report = stream.shutdown().await?;
    println!("committed: {}", report.committed_rows);
    Ok(())
}

§Recover partial progress

Failed operationRecovery accessors
AppendStream::send_allappend_admission()
AppendWriter::writeappend_write_report(), append_input_index()
AppendStream::flush / shutdownappend_delivery_report()
AppendTrySendError converted to Errortry_send_error()
Statement operationsstatement_id(), statement_details()
Catalog mutationscatalog_outcome()

Failed send_all(), write(), flush(), and shutdown() calls always attach their progress reports. These details survive ? and cloning. try_send_error() retains the original AppendTrySendError after conversion to Error.

Admitted rows belong to the stream; use flush() or shutdown() to observe their delivery. A finite-write report (AppendWriteReport) records every scheduled batch in input order, including its input range and commit outcome, and unsubmitted() identifies the suffix that was never sent. Stream delivery reports (AppendDeliveryReport) provide interval counts since the previous completed barrier and are shared across concurrent terminal waiters.

if let Err(error) = stream.shutdown().await {
    let report = error.append_delivery_report().unwrap();
    eprintln!("committed: {}, ambiguous: {}", report.committed_rows, report.ambiguous_rows);
    return Err(error);
}

Always inspect the attached report before replaying failed input, as earlier batches may have committed or finished with AppendOutcome::Ambiguous.

§Determine the append outcome

AppendOutcome describes what the SDK knows about the entire request, not a field to look for in the server response:

SDK outcomeMeaningWhere to read it
SucceededAll request rows committed.AppendRowsResult::status
FailedNo rows took effect or can take effect later.Error::append_details().status
AmbiguousThe request may have taken effect or may still take effect later.Error::append_details().status

A complete HTTP 200 response with a valid, matching num_rows_inserted confirms commit. A valid HTTP 4xx error establishes a definite failure. HTTP 5xx errors, interrupted requests, and invalid responses leave the outcome ambiguous. Local validation can also establish a definite failure before sending a request. A server 408 request_timeout is a definite failure; a client-side timeout is ambiguous.

The ingest API reports failures for the entire batch, without per-row results. Handle the batch as a unit and do not parse diagnostic messages to select rows for replay. After retries, a later definite failure leaves an earlier ambiguous attempt unresolved.

§Decide whether to retry

is_retryable() indicates whether repeating the same SDK call as-is is safe and useful. It returns false when a write or catalog mutation has an uncertain write outcome, when an error carries an aggregate progress report, or when a SQL submission or execution call failed after submission.

Table::append makes one attempt. Finite writers and append streams automatically retry validated HTTP 429 admission refusals within their retry budget. Other 4xx responses require caller handling. Ambiguous outcomes require application reconciliation before replay; .retry_ambiguous(true) explicitly accepts the risk of duplicate rows when retrying transient ambiguous failures. Client-side append timeouts are never retried automatically.

After losing a submission response or a later status-read response, use the ID from error.statement_id() with Client::statement_handle() to inspect the existing execution. Transient polling errors from StatementHandle::refresh() or StatementHandle::wait() can be retried on the same handle.

retries() reports how many retry attempts a failed append request made, and retry_exhausted() indicates whether a retryable failure reached the configured retry limit. AppendRequestResult::retries() and AppendDeliveryReport::retries record retry counts for finite writes and stream intervals.

§Diagnose the failure

http_status() returns the HTTP status, such as 429. code() returns the response body’s string error category, such as too_many_requests. kind() returns the SDK category, such as ErrorKind::RateLimited. These describe the failure; use append_details().status to determine the append’s commit outcome. The HTTP protocol lists the status/code pairs and their recovery guarantees. Known codes must match their HTTP status; a mismatch is InvalidResponse with an ambiguous append outcome. Unrecognized codes are preserved and follow the HTTP status guarantee when the error response is otherwise valid.

details(), request_id(), and retry_after() expose structured diagnostics, the request identifier, and the server’s retry delay from the last failed response. Client-side failures leave code() as None.

After append retries, details() describes the last response, while append_details() preserves AppendOutcome::Ambiguous if any earlier attempt had an ambiguous outcome. Client-side append timeouts also populate write_details().

Display formats the operation, category, and key recovery fields. std::error::Error::source() and Debug expose the underlying transport, serialization, or parse error. Wrap Error as a source in your own error type when attaching application context.

Implementations§

Source§

impl Error

Source

pub fn kind(&self) -> ErrorKind

Returns the failure category.

Source

pub fn message(&self) -> &str

Returns the operation-level error message.

Source

pub fn code(&self) -> Option<&str>

Returns the server error code, if the server supplied one.

This is the response body’s string category, such as too_many_requests. Use http_status for the HTTP status and append_details for an append’s commit outcome.

Source

pub fn details(&self) -> Option<&Value>

Returns the structured server error details from the last failed response.

Source

pub fn http_status(&self) -> Option<StatusCode>

Returns the HTTP status code from the last failed response.

Source

pub fn request_id(&self) -> Option<&str>

Returns the server request ID, if present.

Source

pub fn retry_after(&self) -> Option<Duration>

Returns the server Retry-After delay, if present.

Source

pub fn append_details(&self) -> Option<&AppendErrorDetails>

Returns table-append failure details across all attempts of the failed request.

status remains AppendOutcome::Ambiguous if any attempt had an ambiguous outcome, even when a later attempt failed definitely. row_errors come from the last failed response.

Source

pub fn write_details(&self) -> Option<&WriteErrorDetails>

Returns client-side timeout details when an append attempt timed out.

Source

pub fn catalog_outcome(&self) -> Option<CatalogMutationOutcome>

Returns the commit outcome of a failed catalog mutation.

Returns CatalogMutationOutcome::Unknown when the mutation may have committed, CatalogMutationOutcome::Rejected when the server rejected it without committing, or None for reads, dry runs, and local validation errors.

Source

pub fn statement_id(&self) -> Option<Uuid>

Returns the statement ID associated with a failed statement operation.

Pass this ID to Client::statement_handle to inspect or wait on the execution after a lost submission response or post-submission read failure.

Source

pub fn statement_details(&self) -> Option<&StatementErrorDetails>

Returns structured error details for a statement that terminated in StatementStatus::Failed.

Source

pub fn try_send_error(&self) -> Option<&AppendTrySendError>

Returns the underlying AppendTrySendError when converted into Error.

Source

pub fn append_admission(&self) -> Option<&AppendAdmissionResult>

Returns admission progress for a failed AppendStream::send_all call.

Admitted rows remain owned by the stream. Use flush() or shutdown() to observe their delivery.

Source

pub fn append_write_report(&self) -> Option<&AppendWriteReport>

Returns the per-batch report for a failed AppendWriter::write call.

Source

pub fn append_input_index(&self) -> Option<usize>

Returns the input slice index of the row that failed local encoding in AppendWriter::write.

For server-side row validation errors, map AppendRowError::row_index with AppendRequestResult::input_index.

Source

pub fn append_delivery_report(&self) -> Option<&AppendDeliveryReport>

Returns the terminal delivery report for a failed AppendStream::flush or AppendStream::shutdown.

Source

pub fn is_retryable(&self) -> bool

Returns whether repeating the failed SDK call as-is is safe and useful.

Returns false for unknown write outcomes, aggregate progress reports, and submitted SQL execution errors. Transient status-read failures can be retried on the existing statement handle.

Source

pub fn operation(&self) -> ErrorOperation

Returns the SDK operation that failed.

Source

pub fn retry_exhausted(&self) -> bool

Returns whether a retryable append request exhausted its configured retry limit.

Source

pub fn retries(&self) -> usize

Returns the number of retry attempts made by the failed append request.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

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 Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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
Source§

impl From<AppendTrySendError> for Error

Source§

fn from(error: AppendTrySendError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

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<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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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