Created
August 31, 2018 11:18
-
-
Save myme/6838fd3d639c7945c5e20692d2f03154 to your computer and use it in GitHub Desktop.
Failed pattern match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Krank.API where | |
import Prelude | |
import Control.Monad.Error.Class (throwError) | |
import Data.Either (either) | |
import Effect.Aff (Aff) | |
import Effect.Class (liftEffect) | |
import Effect.Console as C | |
import Effect.Exception (error) | |
import Network.HTTP.Affjax (get) | |
import Network.HTTP.Affjax.Response (string) | |
import Simple.JSON (class ReadForeign, readJSON) | |
-- | Fetch JSON from an API endpoint on the backend. | |
fetchJSON ∷ ∀ a. ReadForeign a => Show a => String → Aff a | |
fetchJSON url = do | |
{ response } ← get string url | |
either onError pure $ readJSON response | |
where | |
onError err = do | |
let desc = "Unable to parse JSON response from " <> url <> ": " <> (show err) | |
liftEffect $ C.error desc | |
throwError $ error $ desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unable to parse JSON response from /krank/commit-api/8107: (NonEmptyList (NonEmpty (ErrorAtProperty "objects" (ErrorAtProperty "attributes" (ErrorAtProperty "params" (ErrorAtProperty "valuespace" (ForeignError "Unable to parse valuespace"))))) ((ErrorAtProperty "objects" (ErrorAtProperty "attributes" (ErrorAtProperty "read" (TypeMismatch "String" "Undefined")))) : (ErrorAtProperty "objects" (ErrorAtProperty "attributes" (ErrorAtProperty "read" (TypeMismatch "String" "Undefined")))) : Nil))) index.js:2178 | |
[Show/hide message details.] TypeError: v is null[Learn More] Aff.purs:88 | |
isLeft | |
Aff.purs:88 | |
join | |
Aff.js:720 | |
join/kills[kid]</< | |
Aff.js:778 | |
<anonymous> | |
Aff.js:669 | |
runEff | |
Aff.js:80 | |
run | |
Aff.js:496 | |
run/step</</< | |
Aff.js:333 | |
drain | |
Aff.js:120 | |
enqueue | |
Aff.js:141 | |
run/step</< | |
Aff.js:330 | |
__do/v1< | |
Compat.purs:25 | |
./.psc-package/psc-0.12.0/affjax/v6.0.0/src/Network/HTTP/Affjax.js/</exports._ajax</</</xhr.onload | |
Affjax.js:60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isLeft | |
src/krank/js/.psc-package/psc-0.12.0/aff/v5.0.0/src/Effect/Aff.purs:88 | |
85 | if (v instanceof Data_Either.Right) { | |
86 | return false; | |
87 | }; | |
> 88 | throw new Error("Failed pattern match at Effect.Aff line 385, column 12 - line 387, column 20: " + [ v.constructor.name ]); | |
89 | }; | |
90 | return { | |
91 | isLeft: isLeft, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment