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

Constructors should throw on fail #21

Open
Samuel-Tyler opened this issue Feb 16, 2020 · 2 comments
Open

Constructors should throw on fail #21

Samuel-Tyler opened this issue Feb 16, 2020 · 2 comments

Comments

@Samuel-Tyler
Copy link
Owner

Currently fast_ber does not throw exceptions. Most functions are labelled noexcept.

However, the only way for constructors to report errors is to throw an exception. Utility should be added such that constructors which may fail throw an error.

Default constructors should not throw.

Any existing functionality that returns an error code should not be affected.

@melg8
Copy link

melg8 commented Mar 7, 2020

I really like your "No exceptions, no RTTI" style approach, so can this be done in some way, so you can disable "throw something;" code on platforms, where exceptions are disabled?

@Samuel-Tyler
Copy link
Owner Author

Sure, I can create a macro such that these failures will abort rather than throw.

In every case where exceptions are needed to report errors (such as constructors and operator=) there will be an alternative method (assign) which will return an error code.

Finally, most functions are currently labelled no except. Functions without this label should be avoided in code with exceptions disabled.

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