bugsnag-types-1.1.0.0: src/Data/Bugsnag/Types/Exception.hs
module Data.Bugsnag.Types.Exception
( Exception (..)
, exampleException
) where
import Data.Bugsnag.Types.Prelude
import Data.Bugsnag.Types.Stackframe
import Data.Bugsnag.Types.ErrorType
data Exception = Exception
{ errorClass :: Text
-- ^ The class of error which occurred. This field is used to group the errors
-- together so should not contain any contextual information that would
-- prevent correct grouping. This would ordinarily be the Exception name when
-- dealing with an exception.
, message :: Maybe Text
-- ^ The error message associated with the error. Usually this will contain some
-- information about this specific instance of the error and is not used to
-- group the errors.
, stacktrace :: [Stackframe]
-- ^ An array of stackframe objects. Each object represents one line in the
-- exception's stacktrace. Bugsnag uses this information to help with error
-- grouping, as well as displaying it to the user.
, type_ :: Maybe ErrorType
-- ^ This should be set for the following platforms so that the stacktrace can be
-- parsed correctly.
}
deriving stock (Eq, Show, Generic)
instance FromJSON Exception where
parseJSON = genericParseJSON aesonOptions
instance ToJSON Exception where
toJSON = genericToJSON aesonOptions
toEncoding = genericToEncoding aesonOptions
exampleException :: Exception
exampleException = Exception
{ errorClass = "NoMethodError"
, message = Just $ "Unable to connect to database"
, stacktrace = [exampleStackframe]
, type_ = Just exampleErrorType
}