Open cdfrey opened 1 year ago
What would you use for cohesive error handling?
@iarfen Hi there!
It's been over a year since I left this, so I had to scan over the code again to try to remember. But I believe I was looking at the operator overloads.
Look at the if statements checking "has_dimentions()" for example. The error case is handled by a call to cerr. The logging is great, but there is no programmatic way to handle the problem. The code continues to run without any further checks or exceptions.
If I call the operator+=() for example, there is a chance that my object will not be modified at all, and I won't know unless I compare it with a copy of itself before the call.
I would suggest that any case that an operation cannot complete, where cerr is called, that an exception also be thrown. If exceptions are not part of the design of this library, then set a flag in the object, so a call to .error() or something can be checked after a number of complex calculations, to know whether it succeeded or not.
Just my $0.02.
After reading through the code at:
https://github.com/scifir/scifir-units/blob/master/units/scalar_unit.cpp
I noticed that there was no cohesive error handling. Perhaps that is a later part of your roadmap? Figured I would mention it anyway, since there is no way to programmatically determine if an operation failed, nor recover if it did. Only messages sent to stderr.