{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}

module Hercules.API.Error where

import Data.OpenApi qualified as O3
import Hercules.API.Prelude

-- | General error type used in (some) HTTP error response bodies and in some
-- resources.
data Error = Error
  { -- | Symbolic names of the error condition; identifiers that clients
    -- may use to identify specific errors or classes of errors.
    Error -> [Text]
errorTags :: [Text],
    -- | Human-readable error message.
    Error -> Text
message :: Text
  }
  deriving ((forall x. Error -> Rep Error x)
-> (forall x. Rep Error x -> Error) -> Generic Error
forall x. Rep Error x -> Error
forall x. Error -> Rep Error x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Error -> Rep Error x
from :: forall x. Error -> Rep Error x
$cto :: forall x. Rep Error x -> Error
to :: forall x. Rep Error x -> Error
Generic, Int -> Error -> ShowS
[Error] -> ShowS
Error -> String
(Int -> Error -> ShowS)
-> (Error -> String) -> ([Error] -> ShowS) -> Show Error
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Error -> ShowS
showsPrec :: Int -> Error -> ShowS
$cshow :: Error -> String
show :: Error -> String
$cshowList :: [Error] -> ShowS
showList :: [Error] -> ShowS
Show, Error -> Error -> Bool
(Error -> Error -> Bool) -> (Error -> Error -> Bool) -> Eq Error
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Error -> Error -> Bool
== :: Error -> Error -> Bool
$c/= :: Error -> Error -> Bool
/= :: Error -> Error -> Bool
Eq)
  deriving anyclass (Error -> ()
(Error -> ()) -> NFData Error
forall a. (a -> ()) -> NFData a
$crnf :: Error -> ()
rnf :: Error -> ()
NFData, [Error] -> Value
[Error] -> Encoding
Error -> Value
Error -> Encoding
(Error -> Value)
-> (Error -> Encoding)
-> ([Error] -> Value)
-> ([Error] -> Encoding)
-> ToJSON Error
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: Error -> Value
toJSON :: Error -> Value
$ctoEncoding :: Error -> Encoding
toEncoding :: Error -> Encoding
$ctoJSONList :: [Error] -> Value
toJSONList :: [Error] -> Value
$ctoEncodingList :: [Error] -> Encoding
toEncodingList :: [Error] -> Encoding
ToJSON, Value -> Parser [Error]
Value -> Parser Error
(Value -> Parser Error)
-> (Value -> Parser [Error]) -> FromJSON Error
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser Error
parseJSON :: Value -> Parser Error
$cparseJSONList :: Value -> Parser [Error]
parseJSONList :: Value -> Parser [Error]
FromJSON, Proxy Error -> Declare (Definitions Schema) NamedSchema
(Proxy Error -> Declare (Definitions Schema) NamedSchema)
-> ToSchema Error
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy Error -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy Error -> Declare (Definitions Schema) NamedSchema
ToSchema, Typeable Error
Typeable Error
-> (Proxy Error -> Declare (Definitions Schema) NamedSchema)
-> ToSchema Error
Proxy Error -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy Error -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy Error -> Declare (Definitions Schema) NamedSchema
O3.ToSchema)