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

OwningHandle::new should allow handle to propagate errors. #19

Closed
jonhoo opened this issue Dec 3, 2016 · 2 comments
Closed

OwningHandle::new should allow handle to propagate errors. #19

jonhoo opened this issue Dec 3, 2016 · 2 comments

Comments

@jonhoo
Copy link

jonhoo commented Dec 3, 2016

If the operation creating the handle fails for some reason, exposing that error is currently quite difficult. Could the signature of new perhaps be changed to

fn new<F, E>(o: O, f: F) -> Result<Self, E>
  where F: Fn(*const O::Target) -> Result<H, E> {}
@Kimundi
Copy link
Owner

Kimundi commented Jan 16, 2017

Sounds reasonable! Instead of changing new, I added an try_new() constructor though.

Check it out on master and tell me if its the expected semantic. :)

jonhoo added a commit to jonhoo/addr2line that referenced this issue Jan 18, 2017
Now that Kimundi/owning-ref-rs#19 has been
resolved with ObjectHandle gaining a try_new method, we can get rid of
the nasty .expect() in Mapping::new_inner, which would panic if the
debug symbols for a given binary were invalid. Now, the error is instead
exposed directly to the caller through the returned Result.
@jonhoo
Copy link
Author

jonhoo commented Jan 18, 2017

try_new seems perfect!

@Kimundi Kimundi closed this as completed Mar 4, 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

No branches or pull requests

2 participants