Skip to content

feat: add terminal error extension - #88

Merged
slinkydeveloper merged 3 commits into
restatedev:mainfrom
sagikazarmark:terminal-error
Jul 21, 2026
Merged

feat: add terminal error extension#88
slinkydeveloper merged 3 commits into
restatedev:mainfrom
sagikazarmark:terminal-error

Conversation

@sagikazarmark

Copy link
Copy Markdown
Contributor

Fixes #87

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Comment thread src/errors.rs Outdated
/// Convert the error into a [`TerminalError`] with the default status code (500).
fn terminal(self) -> Result<T, HandlerError>;
/// Convert the error into a [`TerminalError`] with a custom status code.
fn terminal_with_code(self, code: u16) -> Result<T, HandlerError>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suggest we remove this, and instead add set_code(mut self, code): Self/with_code() to the terminal error itself. In future the terminal error will be extended with other fields, so adding here in this trait all the variants will just pollute the context.

@slinkydeveloper slinkydeveloper left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a small comment, otherwise it's good

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
@sagikazarmark

Copy link
Copy Markdown
Contributor Author

@slinkydeveloper thanks for the review! Makes sense, made the requested change.

Comment thread src/lib.rs Outdated
pub use crate::serde::Json;
}

pub use crate::errors::TerminalErrorExt;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this goes in the prelude?

Comment thread src/errors.rs Outdated
/// Set the status code for this [`TerminalError`].
///
/// ```rust,no_run
/// use restate_sdk::prelude::TerminalError;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// use restate_sdk::prelude::TerminalError;
/// use restate_sdk::prelude::*;

@slinkydeveloper

Copy link
Copy Markdown
Contributor

just two small nits and we can merge

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
@sagikazarmark

Copy link
Copy Markdown
Contributor Author

Done and done :)

@slinkydeveloper

Copy link
Copy Markdown
Contributor

Thank you!

@slinkydeveloper
slinkydeveloper merged commit a6e6dec into restatedev:main Jul 21, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 21, 2026
@sagikazarmark
sagikazarmark deleted the terminal-error branch July 21, 2026 08:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error handling improvement: turn errors into terminal

2 participants