2 ms·
1000% In C, if it can fail, my function always has an error out parameter. void mtt_read_user_file(char* path, mtt_error_t* error); The ease of use benefit
by randyrand 4y ago
1000%
In C, if it can fail, my function always has an error out parameter.
void mtt_read_user_file(char* path, mtt_error_t* error);
The ease of use benefit of having a unified way of checking for errors far outweighs any performance cost.
My errors:
- are binary. "FAIL" vs "SUCCESS"
- hold a chain of user friendly error strings
- have caller controlled behavior, such as turning off error strings to save perf
- can also hold a single error code
- supports being fully preallocated, which I always do at thread creation time. I only need one error object per thread.
I'm quite proud of the error handling in my C code.