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

soroban-rpc: libpreflight: unwrap() errors due to bugs in the Go<->Rust interface #879

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Aug 21, 2023

I understand this can be controversial, but there are good reasons for it. I intentionally created a separate followup PR from #875 in case it meets a strong opposition.

  • panicking will show the line number where the problem happens whereas otherwise we will get an error with no context at all (as an alternative we could add context to every use of ? but that would make the code much more unreadable).

  • We anyhow capture the panics before returning to Go and thus, the process won't stop.

Further context on why it's OK to use unwrap in these cases https://blog.burntsushi.net/unwrap/

Ideally we would simply have a way to selectively attach a backtrace/line-number to these errors instead, but I don't think that will be possible until rust-lang/rust#53487 lands. Also, even then I am not sure we will be able to pick when we want to show backtraces/line numbers (it seems to be all or nothing).

@2opremio 2opremio changed the title Use unwrap() in errors due to bugs in the Go<->Rust interface soroban-rpc: libpreflight: Use unwrap() in errors due to bugs in the Go<->Rust interface Aug 21, 2023
@2opremio 2opremio changed the title soroban-rpc: libpreflight: Use unwrap() in errors due to bugs in the Go<->Rust interface soroban-rpc: libpreflight: unwrap() errors due to bugs in the Go<->Rust interface Aug 21, 2023
* panicking will show the line number where the problem happens whereas
  otherwise we will get an error with no context at all

* We anyhow capture the panics before returning to Go and thus, the
  process won't stop.

Further context on why it's OK to use unwrap in these cases
https://blog.burntsushi.net/unwrap/

Ideally we would have simply have a way to attach a
backtrace/line-number to these errors instead, but I don't think that
will be possible until rust-lang/rust#53487
is ready.
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻

@2opremio 2opremio merged commit 895f8af into stellar:main Aug 21, 2023
19 of 20 checks passed
@2opremio 2opremio deleted the refactor-libpreflight-with-unwrap branch August 21, 2023 23:27
@2opremio
Copy link
Contributor Author

This also addressed part of #858

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants