Skip to content
Snippets Groups Projects
Commit 056640cc authored by Jens Nolte's avatar Jens Nolte
Browse files

Add a type to serialize exceptions


Co-authored-by: default avatarJan Beinke <git@janbeinke.com>
parent 5bb6a10d
No related branches found
No related tags found
No related merge requests found
......@@ -95,6 +95,7 @@ library
exposed-modules:
Quasar.Network
Quasar.Network.Connection
Quasar.Network.Exception
Quasar.Network.Multiplexer
Quasar.Network.Runtime
Quasar.Network.Runtime.Observable
......@@ -107,9 +108,10 @@ test-suite quasar-network-test
import: shared-executable-properties
type: exitcode-stdio-1.0
build-depends:
QuickCheck,
hspec,
quasar-network,
QuickCheck
stm,
main-is: Spec.hs
other-modules:
Quasar.NetworkSpec
......
module Quasar.Network.Exception (
PackedException(..), packException, unpackException
) where
import Control.Exception
import Data.Binary (Binary(..))
import Quasar.Prelude
data PackedException = PackedAnyException AnyException
deriving stock (Show, Eq, Generic)
deriving anyclass Binary
data AnyException = AnyException String
deriving stock (Show, Eq, Generic)
deriving anyclass (Binary, Exception)
packException :: Exception e => e -> PackedException
packException ex = PackedAnyException $ AnyException $ displayException ex
unpackException :: PackedException -> SomeException
unpackException (PackedAnyException ex) = toException ex
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment