packages feed

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

module Data.Bugsnag.Types.Thread
  ( Thread (..)
  , exampleThread
  , defaultThread
  )
where

import Data.Bugsnag.Types.Prelude

import Data.Bugsnag.Types.ErrorType
import Data.Bugsnag.Types.Stackframe

data Thread = Thread
  { id :: Maybe Text
  -- ^ The id of the thread in your application.
  , name :: Maybe Text
  -- ^ A human readable name for the thread.
  , errorReportingThread :: Maybe Bool
  -- ^ If this is the thread that the error was reported from (either an
  -- unhandled error or a call to bugsnag.notify), set this to true.
  , stacktrace :: Maybe [Stackframe]
  -- ^ An array of stacktrace objects. Each object represents one line in the
  -- stacktrace of the thread at the point that the error occurred.
  , state :: Maybe Text
  -- ^ The state of the thread at the time of the error.
  , type_ :: Maybe ErrorType
  }
  deriving stock (Eq, Generic, Show)

instance FromJSON Thread where
  parseJSON = genericParseJSON aesonOptions

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

defaultThread :: Thread
defaultThread =
  Thread
    { id = Nothing
    , name = Nothing
    , errorReportingThread = Nothing
    , stacktrace = Nothing
    , state = Nothing
    , type_ = Nothing
    }

exampleThread :: Thread
exampleThread =
  Thread
    { id = Just "thread_id"
    , name = Just "thread_name"
    , errorReportingThread = Just True
    , stacktrace = Just [exampleStackframe]
    , state = Just "WAITING"
    , type_ = Just exampleErrorType
    }