-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
I'm trying out this library (and purescript) for the first time. The only example of which I am aware is this:
Because the AffJaxResponse
type has a field containing the http status code, I had assumed that errors would be reflected into this field. If I modify the example, I can see that it is set on success:
handler :: forall eff. String -> E.Event (HalogenEffects (ajax :: AJAX | eff)) Input
handler code = E.yield SetBusy `E.andThen` \_ -> E.async compileAff
where
compileAff :: Aff (HalogenEffects (ajax :: AJAX | eff)) Input
compileAff = do
result <- post "http://try.purescript.org/compile/text" code
liftEff $ trace ("status = " ++ show result.status)
let response = result.response
return case readProp "js" response <|> readProp "error" response of
Right js -> SetResult js
Left _ -> SetResult "Invalid response"
If however, I force an error to occur (eg by making the URL invalid), then the code aborts rather than handles the error, as shown in the javascript console.
POST http://try.purescript.zzz/compile/text net::ERR_NAME_NOT_RESOLVED
...
index.js:12251 Uncaught error in asynchronous code: AJAX request failed: POST http://try.purescript.zzz/compile/text
How should the example code be modified to capture errors such they the can can handled appropriately?
Metadata
Metadata
Assignees
Labels
No labels