packages feed

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

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

import Data.Bugsnag.Types.Prelude


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

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
  -- ^ This should be set to indicate the type of runtime the thread was running on so that the stacktrace can be
  -- parsed correctly.
  }
  deriving stock (Eq, Show, Generic)

instance FromJSON Thread where
  parseJSON = genericParseJSON aesonOptions

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

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