@@ -17,7 +17,7 @@ import Effect.Aff.Compat (EffectFnAff, fromEffectFnAff)
17
17
import Effect.Class (liftEffect )
18
18
import Effect.Class.Console as A
19
19
import Effect.Console (log , logShow )
20
- import Effect.Exception ( error , throwException )
20
+ import Effect.Exception as Exn
21
21
import Foreign.Object as FO
22
22
23
23
foreign import logAny :: forall a . a -> Effect Unit
@@ -30,7 +30,7 @@ logAny' :: forall a. a -> Aff Unit
30
30
logAny' = liftEffect <<< logAny
31
31
32
32
assertFail :: forall a . String -> Aff a
33
- assertFail = throwError <<< error
33
+ assertFail = throwError <<< Exn . error
34
34
35
35
assertMsg :: String -> Boolean -> Aff Unit
36
36
assertMsg _ true = pure unit
@@ -51,7 +51,7 @@ assertEq x y =
51
51
when (x /= y) $ assertFail $ " Expected " <> show x <> " , got " <> show y
52
52
53
53
main :: Effect Unit
54
- main = void $ runAff (either (\e -> logShow e *> throwException e) (const $ log " affjax: All good!" )) do
54
+ main = void $ runAff (either (\e -> logShow e *> Exn . throwException e) (const $ log " affjax: All good!" )) do
55
55
let ok200 = StatusCode 200
56
56
let notFound404 = StatusCode 404
57
57
@@ -105,5 +105,10 @@ main = void $ runAff (either (\e -> logShow e *> throwException e) (const $ log
105
105
-- assertEq (Just "test=test") (lookupHeader "Set-Cookie" res.headers)
106
106
107
107
A .log " Testing cancellation"
108
- forkAff (AX .post_ mirror (Just (RequestBody .string " do it now" ))) >>= killFiber (error " Pull the cord!" )
108
+ forkAff (AX .post_ mirror (Just (RequestBody .string " do it now" ))) >>= killFiber (Exn . error " Pull the cord!" )
109
109
assertMsg " Should have been canceled" true
110
+
111
+ A .log " Testing invalid url"
112
+ AX .get ResponseFormat .string " /фыва" >>= assertLeft >>= case _ of
113
+ AX.XHROtherError error → assertEq " Request path contains unescaped characters" (Exn .message error)
114
+ other → logAny' other *> assertFail " Expected a XHROtherError"
0 commit comments