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

[FR] UB_* error codes in unbound.h #576

Closed
FGasper opened this issue Nov 23, 2021 · 2 comments
Closed

[FR] UB_* error codes in unbound.h #576

FGasper opened this issue Nov 23, 2021 · 2 comments

Comments

@FGasper
Copy link
Contributor

FGasper commented Nov 23, 2021

Current behavior
Currently the various libunbound functions report failures via UB_* constants, which unbound.h doesn’t expose. It would be helpful for error handling to have those constants in 3rd-party applications.

Describe the desired feature
Put enum ub_ctx_err into unbound.h so 3rd party apps can access it.

Potential use-case
If I want to translate the errors or otherwise recover from them it’s good to have error codes instead. And it’s ideal not to have to copy-paste them from context.h into my own code.

I’m happy to submit a PR to do this, if it’s an agreeable proposal.

Thank you!

@FGasper
Copy link
Contributor Author

FGasper commented Nov 29, 2021

Thank you @wcawijngaards!

@wcawijngaards
Copy link
Member

Sure, initially wanted to hide these internal details, and expose only the ub_strerror function. Moved the enum to the unbound.h file. Where the enum exists for the purpose of defining the constants only. The enum itself is not used, also not in the source of unbound, so it could really also be a list of #define statements. And use type int for the error return, the enum is not intended to be used as the type for the error codes, only to list the constants.

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