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 error handling #47

Closed

Conversation

Emilgardis
Copy link
Member

@Emilgardis Emilgardis commented Mar 6, 2018

This PR adds error handling via failure. This implementation does however need some work on it as the generated errors doesn't seem matchable in it's current state.

TODO

  1. Change fn(...) -> Result<_,Error> into fn(...) -> Result<_,FnSpecificError>
    This should fix item 2, but I'm not sure.
  2. Make matching more ergonomic and always possible
  3. Add more tests

Part of #46 and #18

The bad_svd test is currently used to see how errors are made.
Also removed tests unrelated to svdparser
This has changed how parsing is done.
All parsing is done in that "modules" _parse function
and mapping of errors are done in parse.
This allows us to wrap every possible source of failure
and apply a context to it.

Also fixed `RegisterClusterArrayInfo::dim_index` where `and_then_result`
could have been used
Also updgraded failure to 0.1.1
There is a problem somewhere, as the PeripheralError in
`register_name_missing` doesn't seem to have a cause.

Also, we have to match differently when we are nested deeper with a
named peripheral. May have to ultimately just have one error for named
and unnamed peripherals/register/etc and implement the display
differently depending on name: Option<String>
@Emilgardis Emilgardis changed the title Feature/error handling Implement error handling Mar 6, 2018
@ryankurte
Copy link
Collaborator

I'm not 💯 on implementing errors yet, but would the solution to match be to expose an SVDError enum to use that collects the implemented error types?

@Emilgardis
Copy link
Member Author

This may all be due to bad usage of failure, but an example of not being able to match on errors is this ignored test.

I am currently looking into implementing failure::Error manually instead of using the #[derive(Fail)].

@Emilgardis
Copy link
Member Author

Work is being reimplemented in the refactor branch

@Emilgardis Emilgardis closed this Mar 17, 2018
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