packages feed

bugsnag-types-1.1.0.1: src/Data/Bugsnag/Types/SeverityReason.hs

module Data.Bugsnag.Types.SeverityReason
  ( SeverityReason (..)
  , exampleSeverityReason
  ) where

import Data.Bugsnag.Types.Prelude

import Data.Bugsnag.Types.SeverityReasonType
import Data.Bugsnag.Types.SeverityReasonAttributes

-- | Information about why the severity was picked.
data SeverityReason = SeverityReason
  { type_ :: Maybe SeverityReasonType
  -- ^ A type key that represents the reason for the assigned severity.
  --
  -- -   @unhandledException@- Whenever an uncaught exception is discovered
  --     (generic).
  -- -   @unhandledError@ - When an error is discovered (PHP).
  -- -   @log@ - Whenever a log message is sent (generic).
  -- -   @signal@ - Whenever a \"fatal\" signal is discovered (iOS).
  -- -   @strictMode@ - Whenever a strictMode issue is discovered (Android).
  -- -   @unhandledPromiseRejection@ Whenever an unhandled promise rejection
  --     is discovered (JS\/Node JS\/React Native).
  -- -   @callbackErrorIntercept@- callbackErrorIntercept (Node JS).
  -- -   @errorClass@ - Whenever an exception with a particular class is
  --     automatically sent (Ruby).
  -- -   @exceptionClass@ - Whenever an exception with a particular class is
  --     automatically sent (Java).
  -- -   @unhandledPanic@ - When a panic is unhandled and crashes the app
  --     (Go).
  -- -   @unhandledErrorMiddleware@ - Unhandled errors in ${Negroni}
  --     middleware have a default severity:error.
  -- -   @unhandledExceptionMiddleware@ - Unhandled exceptions in ${Rack}
  --     middleware have a default severity:error.
  -- -   @userCallbackSetSeverity@ - Whenever a callback changes a report\'s
  --     severity (generic).
  -- -   @userSpecifiedSeverity@ - Whenever a severity is set through a
  --     manual notify call (generic).
  -- -   @handledException@ - Whenever a handled exception is sent through
  --     (generic).
  -- -   @handledError@ - Whenever a handled error is sent through (PHP).
  -- -   @handledPanic@ - Whenever a panic is handled through AutoNotify or
  --     Recover (Go).
  -- -   @userContextSetSeverity@ - When a user creates a context which
  --     changes the severity (Python).
  -- -   @anrError@ - Whenever an ANR is detected (Android).
  -- -   @appHang@ - Whenever an app hang is detected (Cocoa).
  -- -   @outOfMemory@ - When an app is terminated because it used too much
  --     memory (Cocoa).
  -- -   @thermalKill@ - When an app is terminated because the device is
  --     overheating (Cocoa).
  , attributes :: Maybe SeverityReasonAttributes
  , unhandledOverridden :: Maybe Bool
  -- ^ Whether the event\'s @unhandled@ flag was overridden from the
  -- notifier\'s default value.
  }
  deriving stock (Eq, Show, Generic)

instance FromJSON SeverityReason where
  parseJSON = genericParseJSON aesonOptions

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

exampleSeverityReason :: SeverityReason
exampleSeverityReason = SeverityReason
  { type_ = Just exampleSeverityReasonType
  , attributes = Just exampleSeverityReasonAttributes
  , unhandledOverridden = Just False
  }