packages feed

bugsnag-types-1.1.1.0: src/Data/Bugsnag/Types/SeverityReasonAttributes.hs

module Data.Bugsnag.Types.SeverityReasonAttributes
  ( SeverityReasonAttributes (..)
  , exampleSeverityReasonAttributes
  , defaultSeverityReasonAttributes
  )
where

import Data.Bugsnag.Types.Prelude

-- | Optional attributes to provide extra information about the severity
-- reason.
data SeverityReasonAttributes = SeverityReasonAttributes
  { errorType :: Maybe Text
  -- ^ Included for @unhandledError@ severity reason. See
  -- <http://php.net/manual/en/errorfunc.constants.php PHP Error Constants>.
  , level :: Maybe Text
  -- ^ Included for @log@ severity reason.
  , signalType :: Maybe Text
  -- ^ Included for @signal@ severity reason. See
  -- <https://en.wikipedia.org/wiki/C_signal_handling Signal Codes>.
  , violationType :: Maybe Text
  -- ^ Included for @strictMode@ severity reason. See
  -- <https://developer.android.com/reference/android/os/StrictMode.html Strict Mode>.
  , errorClass :: Maybe Text
  -- ^ Included for @errorClass@ severity reason. Specifies the error class
  -- that is automatically sent.
  , framework :: Maybe Text
  -- ^ Included for middleware severity reasons, specifies the middleware that
  -- had an error.
  , exceptionClass :: Maybe Text
  -- ^ Included for @exceptionClass@ severity reason. Specifies the error class
  -- that is automatically sent.
  }
  deriving stock (Eq, Generic, Show)

instance FromJSON SeverityReasonAttributes where
  parseJSON = genericParseJSON aesonOptions

instance ToJSON SeverityReasonAttributes where
  toJSON = genericToJSON aesonOptions
  toEncoding = genericToEncoding aesonOptions

defaultSeverityReasonAttributes :: SeverityReasonAttributes
defaultSeverityReasonAttributes =
  SeverityReasonAttributes
    { errorType = Nothing
    , level = Nothing
    , signalType = Nothing
    , violationType = Nothing
    , errorClass = Nothing
    , framework = Nothing
    , exceptionClass = Nothing
    }

exampleSeverityReasonAttributes :: SeverityReasonAttributes
exampleSeverityReasonAttributes =
  SeverityReasonAttributes
    { errorType = Just "E_ERROR"
    , level = Just "Error"
    , signalType = Just "SIGSEGV"
    , violationType = Just "NetworkOnMainThread"
    , errorClass = Just "ActiveRecord::RecordNotFound"
    , framework = Just "Rack"
    , exceptionClass = Just "TypeMismatchException"
    }