Skip to content

feat: preserve task executor error types with associated errors - #36

Merged
zerosnacks merged 1 commit into
masterfrom
feat/improve-error-handling
Sep 22, 2026
Merged

zerosnacks merged 1 commit into
masterfrom
feat/improve-error-handling

Conversation

@zerosnacks

@zerosnacks zerosnacks commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR improves how Steda handles errors returned by reusable task executors.

Previously, TaskExecutor implementations effectively had to return steda::Error, which pushed downstream projects toward eagerly converting domain errors into Steda errors. In practice, that often meant flattening failures into Error::Other(error.to_string()), losing the original error type and source chain.

This change gives TaskExecutor an associated error type:

pub trait TaskExecutor<Input, Output>: Send + Sync + 'static {
    type Error: Into<steda::Error>;

    // ...
}

This lets executors keep their own typed error enums and use ordinary ? internally.

Error preservation

Steda also gains:

Error::Task(BoxError)

plus Error::task(...), so downstream task errors can be preserved as real error sources instead of being stringified.

A downstream executor can now look like:

impl TaskExecutor<Input, Output> for ExecutionRunner {
    type Error = DurableError;

    async fn execute(
        &self,
        input: Input,
        ctx: TaskContext,
    ) -> Result<Output, Self::Error> {
        let sandbox = attach_sandbox(...).await?;
        let result = run_kernel(...).await?;

        ctx.sleep_for(...).await?;

        Ok(result)
    }
}

with a single conversion into Steda at the outer boundary.

API scope

The closure-based TaskHandler API and TaskContext::step / step_keyed remain steda::Result-based.

This is intentional: making those APIs generic over arbitrary error types caused widespread type inference failures for normal closures that only return Ok(...).

So this change keeps the existing closure ergonomics while allowing reusable executors to preserve their domain error types.

Result

This gives downstream users a cleaner error boundary:

  • reusable executors can use typed domain errors;
  • internal executor code can use normal ?;
  • task error source chains are preserved;
  • Steda converts executor errors only once at registration/execution;
  • closure handlers and checkpoint APIs keep their current inference behavior.

@zerosnacks zerosnacks changed the title Preserve task error source chains without changing task API inference feat: preserve task error source chains without changing task API inference Sep 22, 2026
@zerosnacks zerosnacks closed this Sep 22, 2026
@zerosnacks
zerosnacks force-pushed the feat/improve-error-handling branch from eb0a33c to c2d3e17 Compare September 22, 2026 22:21
@zerosnacks zerosnacks reopened this Sep 22, 2026
@zerosnacks zerosnacks changed the title feat: preserve task error source chains without changing task API inference feat: preserve task executor error types with associated errors Sep 22, 2026
@zerosnacks
zerosnacks merged commit 9a63172 into master Sep 22, 2026
13 of 26 checks passed
@zerosnacks
zerosnacks deleted the feat/improve-error-handling branch September 22, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant