Dombo <do...@disposable.invalid> writes:
>Op 23-Sep-14 22:13, Scott Lurndal schreef:
>> Paavo Helde <
myfir...@osa.pri.ee> writes:
>>> Hongliang Wang <
loud...@gmail.com> wrote in
>>>
news:25e3b7c7-3ecd-4460...@googlegroups.com:
>>>
>>>> Hello all, I used to be a C programmer and my way to print error
>>>> messages is following:
>>>>
>>>> 1. Store all messages in a header file:
>>>>
>>>> /* error.h */
>>>> #define ERROR_01 "Unable to open file: '%s'"
>>>>
>>>> 2. Include that header file in source file and use printf to print
>>>> error messages.
>>>>
>>>> /* source.c */
>>>> if (error) {
>>>> printf(ERROR_01, file_name);
>>>> exit(1);
>>>> }
>>>>
>>>
>>> In C++ errors should be reported via exceptions, the sooner you adapt to
>>> this the better. Exit(1) (or 'return EXIT_FAILURE;') should reside only
>>> in the catch handler in main().
>>
>> Frankly nonsense. Fix the error when it occurs, if possible. If not
>> possible to fix in place (i.e. ask for a new filename if the old one
>> couldn't be opened), log the message and terminate gracefully.
>
>I have once had to deal with library that did that, and that basically
>disqualified that library for use in our application because terminating
Libraries are different. And when I said terminate, that doesn't mean
the error. That can be by returning an error code, or by signaling
an exception. I prefer libraries that return an error code rather than