Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save julianjelfs/cab12ba4206679bc6cde5f580ac844f5 to your computer and use it in GitHub Desktop.

Select an option

Save julianjelfs/cab12ba4206679bc6cde5f580ac844f5 to your computer and use it in GitHub Desktop.
Remote data responding to error
ResultsReceived data ->
( { model | data = data }
, Cmd.none
)
ResultsReceived (Failure err) ->
( { model | data = (Failure err)}
, systemError (toString err)
)
@julianjelfs
Copy link
Author

I am specifically handling the Failure case so that I can fire a Cmd that actually reports the error (via ports)

@krisajenkins
Copy link

I'd do this:

ResultsReceived data ->
    ( { model | data = data }
    , case data of
       Failure err -> systemError <| toString err
       _ ->  Cmd.none
    )

I'd also consider systemError : a -> Cmd msg.

(ie. let it do the toString for you).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment