module Hydra.Contract.DepositError (
  errorCode,
  module Hydra.Contract.DepositError,
) where

import Hydra.Contract.Error (ToErrorCode (..), errorCode)
import Text.Show (Show)

data DepositError
  = DepositDeadlineSurpassed
  | DepositNoUpperBoundDefined
  | DepositNoLowerBoundDefined
  | DepositDeadlineNotReached
  | IncorrectDepositHash
  | DTNotMinted
  deriving stock (Int -> DepositError -> ShowS
[DepositError] -> ShowS
DepositError -> String
(Int -> DepositError -> ShowS)
-> (DepositError -> String)
-> ([DepositError] -> ShowS)
-> Show DepositError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DepositError -> ShowS
showsPrec :: Int -> DepositError -> ShowS
$cshow :: DepositError -> String
show :: DepositError -> String
$cshowList :: [DepositError] -> ShowS
showList :: [DepositError] -> ShowS
Show)

instance ToErrorCode DepositError where
  toErrorCode :: DepositError -> Text
toErrorCode = \case
    DepositError
DepositDeadlineSurpassed -> Text
"D01"
    DepositError
DepositNoUpperBoundDefined -> Text
"D02"
    DepositError
DepositNoLowerBoundDefined -> Text
"D03"
    DepositError
DepositDeadlineNotReached -> Text
"D04"
    DepositError
IncorrectDepositHash -> Text
"D05"
    DepositError
DTNotMinted -> Text
"D06"