Which is kinda not enough. if(...) throw; is okay for simple conditions but doesn't generate a stack trace even if we want to. et_assert just abort the entire program (including cling if using PyEtaler or ROOT) leading to a bad interactive experience. And checkProperties only works for tensors.
So I purpose the following:
We reserve if..... throw; for simple cases
checkProperties is still used for tensor checking
et_assert is for absolutely worst, non-recoverable errors like OOM or internal state mess-ups
a new et_check is used for ordinary condition checking. If the check fails, it throws an EtError and optionally generates a stack trace.
We need a way to generate stack traces pragmatically. It also would be nice to be able to detect the present of cling and use cling for traces when available.
Even tho the C++ standard committee is against using exceptions for programming errors (dtype/shape/backend mismatch is our cases). We consider these user errors - the developers are our users and exceptions gives us a better experiences under an interactive environment. However depending on how contracts are implemented in C++23, it might be a good idea to replace some of the checks with it in the future.
For now, there's three ways to check if an error (or function pre/post condition violation) occurs.
Which is kinda not enough.
if(...) throw;
is okay for simple conditions but doesn't generate a stack trace even if we want to.et_assert
just abort the entire program (including cling if using PyEtaler or ROOT) leading to a bad interactive experience. AndcheckProperties
only works for tensors.So I purpose the following:
if..... throw;
for simple caseset_assert
is for absolutely worst, non-recoverable errors like OOM or internal state mess-upset_check
is used for ordinary condition checking. If the check fails, it throws an EtError and optionally generates a stack trace.Even tho the C++ standard committee is against using exceptions for programming errors (dtype/shape/backend mismatch is our cases). We consider these user errors - the developers are our users and exceptions gives us a better experiences under an interactive environment. However depending on how contracts are implemented in C++23, it might be a good idea to replace some of the checks with it in the future.
Related to #93