fast_ber icon indicating copy to clipboard operation
fast_ber copied to clipboard

Constructors should throw on fail

Open Samuel-Tyler opened this issue 5 years ago • 2 comments

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.

Samuel-Tyler avatar Feb 16 '20 12:02 Samuel-Tyler

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?

melg8 avatar Mar 07 '20 11:03 melg8

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.

Samuel-Tyler avatar Mar 07 '20 11:03 Samuel-Tyler