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

Propagate errno for proper error messages #101

Closed
nh2 opened this issue Jul 15, 2022 · 2 comments · Fixed by #119
Closed

Propagate errno for proper error messages #101

nh2 opened this issue Jul 15, 2022 · 2 comments · Fixed by #119
Labels
enhancement New feature or request

Comments

@nh2
Copy link
Contributor

nh2 commented Jul 15, 2022

I'm using libE57Format through pye57 and noticed that E57_ERROR_OPEN_FAILED is raised for any error, including standard cases such as:

  • no such file or directory
  • permission denied
  • too many open files

Most software can point out these error reasons by consulting errno (e.g. via strerror()), or at least guaranteeing in the API docs to not mess with errno so that the caller can inspect errno themselves.

It would be great if libE57Format could do one of these so that users can get much better error messages along with E57_ERROR_OPEN_FAILED.

@asmaloney asmaloney added the enhancement New feature or request label Jul 15, 2022
@asmaloney
Copy link
Owner

I'm not sure I can guarantee the state of errno, but what I can do is provide the errno & string in the exception context.

So instead of:

result=-1 fileName=./no-path/foo.e57 flags=1538 mode=438

We'd have:

errno=2 error='No such file or directory' fileName=./no-path/foo.e57 flags=1538 mode=438

I don't know what pye57 does with the exception context, but would this solve your issue?

@nh2
Copy link
Contributor Author

nh2 commented Oct 5, 2022

Yes, that would solve the issue!

asmaloney added a commit that referenced this issue Oct 5, 2022
Instead of returning the rather useless "result=-1", return the errno & the error string as "errno=X, error='the reason'".

Fixes #101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants