module Patrol.Type.MachException where
import qualified Data.Aeson as Aeson
import qualified Data.Text as Text
import qualified Patrol.Extra.Aeson as Aeson
data MachException = MachException
{ MachException -> Maybe Int
code :: Maybe Int,
MachException -> Maybe Int
exception :: Maybe Int,
MachException -> Text
name :: Text.Text,
MachException -> Maybe Int
subcode :: Maybe Int
}
deriving (MachException -> MachException -> Bool
(MachException -> MachException -> Bool)
-> (MachException -> MachException -> Bool) -> Eq MachException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MachException -> MachException -> Bool
== :: MachException -> MachException -> Bool
$c/= :: MachException -> MachException -> Bool
/= :: MachException -> MachException -> Bool
Eq, Int -> MachException -> ShowS
[MachException] -> ShowS
MachException -> String
(Int -> MachException -> ShowS)
-> (MachException -> String)
-> ([MachException] -> ShowS)
-> Show MachException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MachException -> ShowS
showsPrec :: Int -> MachException -> ShowS
$cshow :: MachException -> String
show :: MachException -> String
$cshowList :: [MachException] -> ShowS
showList :: [MachException] -> ShowS
Show)
instance Aeson.ToJSON MachException where
toJSON :: MachException -> Value
toJSON MachException
machException =
[Pair] -> Value
Aeson.intoObject
[ String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"code" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ MachException -> Maybe Int
code MachException
machException,
String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"exception" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ MachException -> Maybe Int
exception MachException
machException,
String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"name" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ MachException -> Text
name MachException
machException,
String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"subcode" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ MachException -> Maybe Int
subcode MachException
machException
]
empty :: MachException
empty :: MachException
empty =
MachException
{ code :: Maybe Int
code = Maybe Int
forall a. Maybe a
Nothing,
exception :: Maybe Int
exception = Maybe Int
forall a. Maybe a
Nothing,
name :: Text
name = Text
Text.empty,
subcode :: Maybe Int
subcode = Maybe Int
forall a. Maybe a
Nothing
}