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

Implement the Error trait on ws Error type #117

Merged
merged 2 commits into from
Apr 19, 2017

Conversation

faern
Copy link
Contributor

@faern faern commented Apr 19, 2017

Implement the Error trait on the websocket server error type. Same reason as in #97


impl ::std::error::Error for Error {
fn description(&self) -> &str {
"Starting the JSON-RPC WebSocket server failed"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not delegate to wrapped errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted them to work the same as the http errors. Also a chain of errors (this is one error and it contains a cause that is another error) should not just chain down transparently. The intermediate steps in the chain must have relevant information, otherwise there is no information why one got the bottom level error one got.

Instead of just delegating this down one might even want to change the display implementation to be "Starting the JSON-RPC WebSocket server failed: {}" and then format in the cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have been looking in the rustc code for any standard on how the description and Display are implemented. But I could not find a common denominator for enums containing sub-errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough! 👍

@tomusdrw
Copy link
Contributor

Could you merge with latest master so that we can see that the tests are not failing?

@faern
Copy link
Contributor Author

faern commented Apr 19, 2017

@tomusdrw It is based on the latest master? Or should I merge it with master on my fork, what does that help with?

@faern
Copy link
Contributor Author

faern commented Apr 19, 2017

@tomusdrw Latest master fails with the same error on my machine as well.

@tomusdrw
Copy link
Contributor

Oh, ok sorry. It's probably caused by a Cargo.lock file locally, for travis is must be cache. Will re-run the builds.

@tomusdrw
Copy link
Contributor

Sorry once again, actually I thought that the fix is already merged, but I just made a PR: #119
You can wait for that one to be merged or just replace set_body(b"Hello World") -> set_body("Hello World".to_owned()).

@faern
Copy link
Contributor Author

faern commented Apr 19, 2017

@tomusdrw Fixed. Should hopefully build now.

@faern
Copy link
Contributor Author

faern commented Apr 19, 2017

Now nightly crashes on something else. But I get that locally as well. It's a bug that I think is reported on rustc already.

@tomusdrw
Copy link
Contributor

Yeah, the crash is irrelevant. Thank you so much for the PR!

@tomusdrw tomusdrw merged commit 46ee883 into paritytech:master Apr 19, 2017
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.

None yet

2 participants