Simpler error handling for lhttpc users #10

Merged
merged 1 commit into from Apr 10, 2012
Commits on Apr 5, 2012
  1. @fdmanana

    Simpler error handling

    fdmanana committed Apr 5, 2012
    On error we now always get a response of the form
    {error, Reason} instead of either getting such a
    response or an exit (which is undocumented).
    This simplifies code which wants to deal with all
    possible errors, for example:
    
        try
            case lhttpc:send_body_part(UploadState, BodyPart, Timeout) of
            {ok, UploadState2} ->
                loop(UpfateState2, Timeout);
            {error, Reason} ->
                handle_error(Reason)
             end
         catch exit:ExitReason ->
             handle_error(ExitReason)
         end
    
    Would become simply:
    
        case lhttpc:send_body_part(UploadState, BodyPart, Timeout) of
        {ok, UploadState2} ->
            loop(UpfateState2, Timeout);
        {error, Reason} ->
            handle_error(Reason)
        end