Topic: Error handling
Author: jsphadetula@gmail.com
Date: Fri, 6 Feb 2015 20:55:14 -0800 (PST)
Raw View
------=_Part_1141_273948469.1423284914922
Content-Type: text/plain; charset=UTF-8
For critical code as discussed recently by ZeroMQ maintainer, i think an alternative error handling technique other than return value is needed in C++ since that will not work with constructors.
Using a threadlocal storage like errno in C language but managed by the compiler I think will be better.
To avoid the known issue of not checking for errors with return codes any attempt to set an error condition when there is an existing error will throw an exception
Added to that is also making the runtime throw exception when leaving the current executing function with error state not being zero to show no errors except the programmer as hinted the runtime to allow the error to propagate to the outer context
This will leave the current modern C++ as is, avoid mixing function signatures with error handling as done with return codes but also enforce error handling throwing exception when the current error state is about to be overridden
This might mean that the standard library be engineered around a standard error code scheme and optionally setting error message which can then be converted into the appropriate exceptions when not handled
Finally adding such feature will only complement but not replace exceptions but allow exceptions to be used only for exceptional cases
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1141_273948469.1423284914922--
.