[erlang-questions] Fault injection for testing?

Attila Rajmund Nohl attila.r.nohl@REDACTED
Mon Dec 20 15:16:39 CET 2010


2010/12/20, Tomasz Maciejewski <ponton@REDACTED>:
> 2010/12/20 Attila Rajmund Nohl <attila.r.nohl@REDACTED>:
>> Hello!
>>
>> Testing error handling is complicated, because it might be hard to
>> cause the error situation in the first place, which in my case it's a
>> file writing error:
>>
>>    case file:write_file(FileName, <<Index:8/integer>>) of
>>        ok -> ok;
>>        Error ->
>>            io:format(standard_error, "~p ~p Error: '~p' ~n", [?MODULE,
>> ?LINE, Error]),
>>            exit(open_lastwritten_file)
>>    end.
>
> You don't need to print error messages by calling io:format. The
> error_logger module will do it whenever a process crash. You can set
> it to write to file and then you can read it with Report Browser.

Yeah, unless you want to log errors in the error_logger. In which case
it leads to deadlock I've experienced first hand...


More information about the erlang-questions mailing list