On 02/04/2013 01:24 PM, Markus Armbruster wrote:
> Fabien Chouteau <chout...@adacore.com> writes:
> 
>> On 02/04/2013 11:34 AM, Markus Armbruster wrote:
>>
>> Why? The caller doesn't know the difference between Windows/Linux
>> implementation. And the error handling would have to be duplicated.
> 
> The function's (implied) contract is to return an error code without
> printing anything.  If you want to change the contract to include
> reporting the error, you need to implement it both for both arms of the
> #ifdef.  You also have to demonstrate that all callers are happy with
> the change of contract.
> 
> Regardless, printing to stderr is wrong.  The function can be called on
> behalf of a monitor command, and then the error needs to be printed to
> the correct monitor.  error_report() can do that for you, and more.
> 

Alright, so I will use error_report() and do it for both Linux and Windows.

>> It's not the first time I add error output in Windows code. Specially in
>> block/, when there's an error, the only thing you get is: "operation not
>> permitted". It's not very helpful and you have to dig in the code to
>> find which function failed.
> 
> Good error reporting is hard.  Knowledge about the error and its context
> gets lost as you move up the call chain.  Knowledge about how to report
> errors gets lost as you move down.
> 

You're right, and in my opinion, no error reporting is the worst case.

-- 
Fabien Chouteau

Reply via email to