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

Refactor error handling #112

Closed
robo9k opened this issue Sep 28, 2023 · 2 comments
Closed

Refactor error handling #112

robo9k opened this issue Sep 28, 2023 · 2 comments

Comments

@robo9k
Copy link
Owner

robo9k commented Sep 28, 2023

I'm not quite happy with the current error handling.
There's one MagicError enum for aynthing that can go wrong in the crate and one opaque FfiError for anything that can go wrong when calling libmagic.

I think each function should return a specific error enum that only has the cases that can go wrong in that particular function.
For API stability, maybe the cases should currently not expose more than std:error::Error.
LibmagicError::ApiViolation should rather be an assertion. There's not much the user can do in that case and it might even be unsafe to keep using libmagic in that case.

Some references:

For user convenvience, maybe the one magic "whatever" type should be available to convert into.

thiserror is pretty conventient for development, but adds to dependencies and compile time. Maybe it could be replaced with cargo expand code once the dust has settled.

@robo9k
Copy link
Owner Author

robo9k commented Sep 29, 2023

@robo9k
Copy link
Owner Author

robo9k commented Sep 30, 2023

Implemented in #113 and #122

There's no catch-all error for the whole crate.
thiserror is still a dependency.

@robo9k robo9k closed this as completed Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant