file:read_line - conflicting return values' syntax - no case clause matching eof exception

Kay Kay kaykay.unique@REDACTED
Mon Feb 15 08:59:31 CET 2010


As per the documentation here -

http://ftp.sunet.se/pub/lang/erlang/doc/man/file.html#read_line-1  ,
the syntax reads as -

read_line(IoDevice) -> {ok, Data} | eof | {error, Reason}

Given the ambiguity in the return values of the function , I am unsure 
how to handle it.



do_read_file(IoDevice, InData, Accum) ->
   case file:read_line(IoDevice) of
     {'ok', Data}  ->
       do_read_file(IoDevice, Data, lists:append(Accum, InData));
     { 'eof' } ->
       Accum
    end.


I wrote this function to use the same, but I am getting - "** exception 
error: no case clause matching eof" .

What is the best way to handle the same ?




More information about the erlang-questions mailing list