Pretty print.
parent
78e1922178
commit
0671e1780c
|
@ -8,7 +8,7 @@ import Data.Array as A
|
||||||
import Data.Tuple (Tuple(..))
|
import Data.Tuple (Tuple(..))
|
||||||
import Data.Bifunctor (lmap)
|
import Data.Bifunctor (lmap)
|
||||||
-- import Data.Codec.Argonaut (JsonCodec, JsonDecodeError)
|
-- import Data.Codec.Argonaut (JsonCodec, JsonDecodeError)
|
||||||
-- import Data.Codec.Argonaut as CA
|
import Data.Codec.Argonaut as CA
|
||||||
import Data.Const (Const)
|
import Data.Const (Const)
|
||||||
import Data.Either (Either(..))
|
import Data.Either (Either(..))
|
||||||
import Data.Maybe (Maybe(..), isJust, isNothing, maybe)
|
import Data.Maybe (Maybe(..), isJust, isNothing, maybe)
|
||||||
|
@ -336,7 +336,7 @@ handleAction = case _ of
|
||||||
case err of
|
case err of
|
||||||
(AuthD.JSONERROR jerr) -> do
|
(AuthD.JSONERROR jerr) -> do
|
||||||
print_json_string messageEvent.message
|
print_json_string messageEvent.message
|
||||||
handleAction $ WebSocketParseError ("Parsing error: AuthD.JSONERROR" <> (show jerr))
|
handleAction $ WebSocketParseError ("JSON parsing error:" <> (CA.printJsonDecodeError jerr))
|
||||||
(AuthD.UnknownError unerr) -> handleAction $ WebSocketParseError ("Parsing error: AuthD.UnknownError" <> (show unerr))
|
(AuthD.UnknownError unerr) -> handleAction $ WebSocketParseError ("Parsing error: AuthD.UnknownError" <> (show unerr))
|
||||||
(AuthD.UnknownNumber ) -> handleAction $ WebSocketParseError ("Parsing error: AuthD.UnknownNumber")
|
(AuthD.UnknownNumber ) -> handleAction $ WebSocketParseError ("Parsing error: AuthD.UnknownNumber")
|
||||||
-- Cases where we understood the message.
|
-- Cases where we understood the message.
|
||||||
|
@ -444,12 +444,10 @@ foreignToArrayBuffer
|
||||||
renderForeignErrors =
|
renderForeignErrors =
|
||||||
String.joinWith "; " <<< A.fromFoldable <<< map F.renderForeignError
|
String.joinWith "; " <<< A.fromFoldable <<< map F.renderForeignError
|
||||||
|
|
||||||
-- print_json_string :: forall m. MonadState State m => ArrayBuffer -> m Unit
|
|
||||||
-- print_json_string :: forall (m :: Type -> Type) (a :: Type). MonadEffect m => Effect a -> m a
|
|
||||||
print_json_string :: forall m. MonadEffect m => MonadState State m => ArrayBuffer -> m Unit
|
print_json_string :: forall m. MonadEffect m => MonadState State m => ArrayBuffer -> m Unit
|
||||||
print_json_string arraybuffer = do
|
print_json_string arraybuffer = do
|
||||||
-- fromTypedIPC :: ArrayBuffer -> Effect (Either ParseError (Tuple UInt String))
|
-- fromTypedIPC :: ArrayBuffer -> Effect (Either ParseError (Tuple UInt String))
|
||||||
value <- H.liftEffect $ IPC.fromTypedIPC arraybuffer
|
value <- H.liftEffect $ IPC.fromTypedIPC arraybuffer
|
||||||
appendMessage $ case (value) of
|
appendMessage $ case (value) of
|
||||||
Left _ -> "Cannot even fromTypedIPC the message."
|
Left _ -> "Cannot even fromTypedIPC the message."
|
||||||
Right (Tuple messageTypeNumber string) -> "Number is: " <> show messageTypeNumber <> "Received string: " <> string
|
Right (Tuple messageTypeNumber string) -> "Number is: " <> show messageTypeNumber <> ", received string: " <> string
|
||||||
|
|
|
@ -160,9 +160,9 @@ decode number json
|
||||||
|
|
||||||
-- Related JSON codecs.
|
-- Related JSON codecs.
|
||||||
codecGotError ∷ CA.JsonCodec Error
|
codecGotError ∷ CA.JsonCodec Error
|
||||||
codecGotError = CA.object "Error" (CAR.record { reason: CAR.optional CA.string })
|
codecGotError = CA.object "Error" (CAR.record { "reason": CAR.optional CA.string })
|
||||||
codecGotToken ∷ CA.JsonCodec Token
|
codecGotToken ∷ CA.JsonCodec Token
|
||||||
codecGotToken = CA.object "Token" (CAR.record { uid: CA.int, token: CA.string })
|
codecGotToken = CA.object "Token" (CAR.record { "uid": CA.int, "token": CA.string })
|
||||||
codecGotContacts ∷ CA.JsonCodec Contacts
|
codecGotContacts ∷ CA.JsonCodec Contacts
|
||||||
codecGotContacts = CA.object "Contacts" (CAR.record { user: CA.int, email: CAR.optional CA.string, phone: CAR.optional CA.string })
|
codecGotContacts = CA.object "Contacts" (CAR.record { user: CA.int, email: CAR.optional CA.string, phone: CAR.optional CA.string })
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue