title: Elm : Decode Http.Error
body: <p>I'm wondering how to decode an Http.Error in elm and store it's data on my model.</p>
  
  <p>I know that the error response is going to return this structure.</p>
  
  <pre><code>{
    error: "Some error message",
    ok: false
  }
  </code></pre>
  
  <p>Here are my models and my Http request</p>
  
  <pre><code>type alias Model =
    { url = String
    , result : String
    , errorMessage : String
    , error : Bool
    }
  
  model : Model
  model =
    { url = ""
    , result = ""
    , errorMessage = ""
    , error = False
    }
  
  -- make the request
  
  makeRequest : String -&gt; Cmd Msg
  makeRequest url =
    Task.perform FetchFail FetchSucceed (Http.get decodeTitle url)
  
  -- decode the success response
  
  decodeTitle : Json.Decoder String
  decodeTitle =
    Json.at ["title"] Json.string
  
  -- decode the error
  
  decodeError =
    Json.object2 User
      ("error" := Json.string)
      ("ok" := Json.bool)
  </code></pre>
  
  <p>I was hoping I could handle this in <code>FetchFail</code> of my update like so.</p>
  
  <pre><code>type Msg
    = FetchTitle
    | FetchSucceed String
    | FetchFail Http.Error
  
  
  update : Msg -&gt; Model -&gt; (Model, Cmd Msg)
  update action model =
    case action of
      ...
  
      FetchFail err -&gt;
        let
          error =
            decodeError error
        in
          ({ model | ok = error.ok, errorMessage = error.error}, Cmd.none)
  </code></pre>
  
  <p>Any help is appreciated.</p>