Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling in the Bridge #319

Merged
merged 7 commits into from
Feb 17, 2025
Merged

Error handling in the Bridge #319

merged 7 commits into from
Feb 17, 2025

Conversation

charypar
Copy link
Member

@charypar charypar commented Feb 17, 2025

This is a breaking change

It allows serde and resolve errors in the bridge to be caught and inspected, so instead of crashing the core, they can be passed to telemetry, etc.

to do

  • introduce results, error types etc
  • add tests for the various bridge failures, check the errors provide enough info

Copy link
Member

@StuartHarris StuartHarris left a comment

Choose a reason for hiding this comment

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

Nice! Just couple of nits;

ResolveSerialized::Once(_) => {
// The resolve has been used, turn it into a Never
if let ResolveSerialized::Once(f) =
std::mem::replace(self, ResolveSerialized::Never)
{
f(bytes);
f(bytes)?
Copy link
Member

Choose a reason for hiding this comment

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

should this be a return?

Copy link
Member

Choose a reason for hiding this comment

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

I suppose it works because it's a result of unit type, just confusing because there's no semicolon, I guess

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah you're right, that just happens to be the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote with let else and unreachable

@@ -21,15 +21,24 @@ lazy_static! {

#[wasm_bindgen]
pub fn process_event(data: &[u8]) -> Vec<u8> {
CORE.process_event(data)
match CORE.process_event(data) {
Copy link
Member

Choose a reason for hiding this comment

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

Aren't these effectively just unwrap()?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the difference is just the message you get - the errors format pretty nicely.

@charypar charypar merged commit d08ca6f into master Feb 17, 2025
9 checks passed
@charypar charypar deleted the viktor/bridge-error-handling branch February 17, 2025 15:00
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.

2 participants