-- | Definitions of exception types.
module Database.PostgreSQL.PQTypes.Internal.Error
  ( DetailedQueryError (..)
  , QueryError (..)
  , HPQTypesError (..)
  , LibPQError (..)
  , ConversionError (..)
  , ArrayItemError (..)
  , InvalidValue (..)
  , RangeError (..)
  , ArrayDimensionMismatch (..)
  , RowLengthMismatch (..)
  , AffectedRowsMismatch (..)
  ) where

import Control.Exception qualified as E
import Data.Typeable

import Database.PostgreSQL.PQTypes.Internal.Error.Code

-- | SQL query error. Reference: description of PQresultErrorField
-- at <http://www.postgresql.org/docs/devel/static/libpq-exec.html>.
data DetailedQueryError = DetailedQueryError
  { DetailedQueryError -> String
qeSeverity :: !String
  , DetailedQueryError -> ErrorCode
qeErrorCode :: !ErrorCode
  , DetailedQueryError -> String
qeMessagePrimary :: !String
  , DetailedQueryError -> Maybe String
qeMessageDetail :: !(Maybe String)
  , DetailedQueryError -> Maybe String
qeMessageHint :: !(Maybe String)
  , DetailedQueryError -> Maybe Int
qeStatementPosition :: !(Maybe Int)
  , DetailedQueryError -> Maybe Int
qeInternalPosition :: !(Maybe Int)
  , DetailedQueryError -> Maybe String
qeInternalQuery :: !(Maybe String)
  , DetailedQueryError -> Maybe String
qeContext :: !(Maybe String)
  , DetailedQueryError -> Maybe String
qeSourceFile :: !(Maybe String)
  , DetailedQueryError -> Maybe Int
qeSourceLine :: !(Maybe Int)
  , DetailedQueryError -> Maybe String
qeSourceFunction :: !(Maybe String)
  }
  deriving (DetailedQueryError -> DetailedQueryError -> Bool
(DetailedQueryError -> DetailedQueryError -> Bool)
-> (DetailedQueryError -> DetailedQueryError -> Bool)
-> Eq DetailedQueryError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DetailedQueryError -> DetailedQueryError -> Bool
== :: DetailedQueryError -> DetailedQueryError -> Bool
$c/= :: DetailedQueryError -> DetailedQueryError -> Bool
/= :: DetailedQueryError -> DetailedQueryError -> Bool
Eq, Eq DetailedQueryError
Eq DetailedQueryError =>
(DetailedQueryError -> DetailedQueryError -> Ordering)
-> (DetailedQueryError -> DetailedQueryError -> Bool)
-> (DetailedQueryError -> DetailedQueryError -> Bool)
-> (DetailedQueryError -> DetailedQueryError -> Bool)
-> (DetailedQueryError -> DetailedQueryError -> Bool)
-> (DetailedQueryError -> DetailedQueryError -> DetailedQueryError)
-> (DetailedQueryError -> DetailedQueryError -> DetailedQueryError)
-> Ord DetailedQueryError
DetailedQueryError -> DetailedQueryError -> Bool
DetailedQueryError -> DetailedQueryError -> Ordering
DetailedQueryError -> DetailedQueryError -> DetailedQueryError
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DetailedQueryError -> DetailedQueryError -> Ordering
compare :: DetailedQueryError -> DetailedQueryError -> Ordering
$c< :: DetailedQueryError -> DetailedQueryError -> Bool
< :: DetailedQueryError -> DetailedQueryError -> Bool
$c<= :: DetailedQueryError -> DetailedQueryError -> Bool
<= :: DetailedQueryError -> DetailedQueryError -> Bool
$c> :: DetailedQueryError -> DetailedQueryError -> Bool
> :: DetailedQueryError -> DetailedQueryError -> Bool
$c>= :: DetailedQueryError -> DetailedQueryError -> Bool
>= :: DetailedQueryError -> DetailedQueryError -> Bool
$cmax :: DetailedQueryError -> DetailedQueryError -> DetailedQueryError
max :: DetailedQueryError -> DetailedQueryError -> DetailedQueryError
$cmin :: DetailedQueryError -> DetailedQueryError -> DetailedQueryError
min :: DetailedQueryError -> DetailedQueryError -> DetailedQueryError
Ord, Int -> DetailedQueryError -> ShowS
[DetailedQueryError] -> ShowS
DetailedQueryError -> String
(Int -> DetailedQueryError -> ShowS)
-> (DetailedQueryError -> String)
-> ([DetailedQueryError] -> ShowS)
-> Show DetailedQueryError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DetailedQueryError -> ShowS
showsPrec :: Int -> DetailedQueryError -> ShowS
$cshow :: DetailedQueryError -> String
show :: DetailedQueryError -> String
$cshowList :: [DetailedQueryError] -> ShowS
showList :: [DetailedQueryError] -> ShowS
Show)

-- | Simple SQL query error. Thrown when there is no
-- PGresult object corresponding to query execution.
newtype QueryError = QueryError String
  deriving (QueryError -> QueryError -> Bool
(QueryError -> QueryError -> Bool)
-> (QueryError -> QueryError -> Bool) -> Eq QueryError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: QueryError -> QueryError -> Bool
== :: QueryError -> QueryError -> Bool
$c/= :: QueryError -> QueryError -> Bool
/= :: QueryError -> QueryError -> Bool
Eq, Eq QueryError
Eq QueryError =>
(QueryError -> QueryError -> Ordering)
-> (QueryError -> QueryError -> Bool)
-> (QueryError -> QueryError -> Bool)
-> (QueryError -> QueryError -> Bool)
-> (QueryError -> QueryError -> Bool)
-> (QueryError -> QueryError -> QueryError)
-> (QueryError -> QueryError -> QueryError)
-> Ord QueryError
QueryError -> QueryError -> Bool
QueryError -> QueryError -> Ordering
QueryError -> QueryError -> QueryError
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: QueryError -> QueryError -> Ordering
compare :: QueryError -> QueryError -> Ordering
$c< :: QueryError -> QueryError -> Bool
< :: QueryError -> QueryError -> Bool
$c<= :: QueryError -> QueryError -> Bool
<= :: QueryError -> QueryError -> Bool
$c> :: QueryError -> QueryError -> Bool
> :: QueryError -> QueryError -> Bool
$c>= :: QueryError -> QueryError -> Bool
>= :: QueryError -> QueryError -> Bool
$cmax :: QueryError -> QueryError -> QueryError
max :: QueryError -> QueryError -> QueryError
$cmin :: QueryError -> QueryError -> QueryError
min :: QueryError -> QueryError -> QueryError
Ord, Int -> QueryError -> ShowS
[QueryError] -> ShowS
QueryError -> String
(Int -> QueryError -> ShowS)
-> (QueryError -> String)
-> ([QueryError] -> ShowS)
-> Show QueryError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> QueryError -> ShowS
showsPrec :: Int -> QueryError -> ShowS
$cshow :: QueryError -> String
show :: QueryError -> String
$cshowList :: [QueryError] -> ShowS
showList :: [QueryError] -> ShowS
Show)

-- | Internal error in this library.
newtype HPQTypesError = HPQTypesError String
  deriving (HPQTypesError -> HPQTypesError -> Bool
(HPQTypesError -> HPQTypesError -> Bool)
-> (HPQTypesError -> HPQTypesError -> Bool) -> Eq HPQTypesError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HPQTypesError -> HPQTypesError -> Bool
== :: HPQTypesError -> HPQTypesError -> Bool
$c/= :: HPQTypesError -> HPQTypesError -> Bool
/= :: HPQTypesError -> HPQTypesError -> Bool
Eq, Eq HPQTypesError
Eq HPQTypesError =>
(HPQTypesError -> HPQTypesError -> Ordering)
-> (HPQTypesError -> HPQTypesError -> Bool)
-> (HPQTypesError -> HPQTypesError -> Bool)
-> (HPQTypesError -> HPQTypesError -> Bool)
-> (HPQTypesError -> HPQTypesError -> Bool)
-> (HPQTypesError -> HPQTypesError -> HPQTypesError)
-> (HPQTypesError -> HPQTypesError -> HPQTypesError)
-> Ord HPQTypesError
HPQTypesError -> HPQTypesError -> Bool
HPQTypesError -> HPQTypesError -> Ordering
HPQTypesError -> HPQTypesError -> HPQTypesError
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: HPQTypesError -> HPQTypesError -> Ordering
compare :: HPQTypesError -> HPQTypesError -> Ordering
$c< :: HPQTypesError -> HPQTypesError -> Bool
< :: HPQTypesError -> HPQTypesError -> Bool
$c<= :: HPQTypesError -> HPQTypesError -> Bool
<= :: HPQTypesError -> HPQTypesError -> Bool
$c> :: HPQTypesError -> HPQTypesError -> Bool
> :: HPQTypesError -> HPQTypesError -> Bool
$c>= :: HPQTypesError -> HPQTypesError -> Bool
>= :: HPQTypesError -> HPQTypesError -> Bool
$cmax :: HPQTypesError -> HPQTypesError -> HPQTypesError
max :: HPQTypesError -> HPQTypesError -> HPQTypesError
$cmin :: HPQTypesError -> HPQTypesError -> HPQTypesError
min :: HPQTypesError -> HPQTypesError -> HPQTypesError
Ord)

instance Show HPQTypesError where
  show :: HPQTypesError -> String
show (HPQTypesError String
s) = String
"HPQTypesError (PostgreSQL): " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
s

-- | Internal error in libpq/libpqtypes library.
newtype LibPQError = LibPQError String
  deriving (LibPQError -> LibPQError -> Bool
(LibPQError -> LibPQError -> Bool)
-> (LibPQError -> LibPQError -> Bool) -> Eq LibPQError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LibPQError -> LibPQError -> Bool
== :: LibPQError -> LibPQError -> Bool
$c/= :: LibPQError -> LibPQError -> Bool
/= :: LibPQError -> LibPQError -> Bool
Eq, Eq LibPQError
Eq LibPQError =>
(LibPQError -> LibPQError -> Ordering)
-> (LibPQError -> LibPQError -> Bool)
-> (LibPQError -> LibPQError -> Bool)
-> (LibPQError -> LibPQError -> Bool)
-> (LibPQError -> LibPQError -> Bool)
-> (LibPQError -> LibPQError -> LibPQError)
-> (LibPQError -> LibPQError -> LibPQError)
-> Ord LibPQError
LibPQError -> LibPQError -> Bool
LibPQError -> LibPQError -> Ordering
LibPQError -> LibPQError -> LibPQError
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LibPQError -> LibPQError -> Ordering
compare :: LibPQError -> LibPQError -> Ordering
$c< :: LibPQError -> LibPQError -> Bool
< :: LibPQError -> LibPQError -> Bool
$c<= :: LibPQError -> LibPQError -> Bool
<= :: LibPQError -> LibPQError -> Bool
$c> :: LibPQError -> LibPQError -> Bool
> :: LibPQError -> LibPQError -> Bool
$c>= :: LibPQError -> LibPQError -> Bool
>= :: LibPQError -> LibPQError -> Bool
$cmax :: LibPQError -> LibPQError -> LibPQError
max :: LibPQError -> LibPQError -> LibPQError
$cmin :: LibPQError -> LibPQError -> LibPQError
min :: LibPQError -> LibPQError -> LibPQError
Ord)

instance Show LibPQError where
  show :: LibPQError -> String
show (LibPQError String
s) = String
"LibPQError (PostgreSQL): " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
s

-- | Data conversion error. Since it's polymorphic in error type,
-- it nicely reports arbitrarily nested conversion errors.
data ConversionError = forall e. E.Exception e => ConversionError
  { ConversionError -> Int
convColumn :: !Int
  -- ^ Column number (Starts with 1).
  , ConversionError -> String
convColumnName :: !String
  -- ^ Name of the column.
  , ConversionError -> Int
convRow :: !Int
  -- ^ Row number (Starts with 1).
  , ()
convError :: !e
  -- ^ Exact error.
  }

deriving instance Show ConversionError

-- | Array item error. Polymorphic in error type
-- for the same reason as 'ConversionError'.
data ArrayItemError = forall e. E.Exception e => ArrayItemError
  { ArrayItemError -> Int
arrItemIndex :: !Int
  -- ^ Item index (Starts with 1).
  , ()
arrItemError :: !e
  -- ^ Exact error.
  }

deriving instance Show ArrayItemError

-- | \"Invalid value\" error for various data types.
data InvalidValue t = InvalidValue
  { forall t. InvalidValue t -> t
ivValue :: t
  -- ^ Invalid value.
  , -- Optional list of valid values.
    forall t. InvalidValue t -> Maybe [t]
ivValidValues :: Maybe [t]
  }
  deriving (InvalidValue t -> InvalidValue t -> Bool
(InvalidValue t -> InvalidValue t -> Bool)
-> (InvalidValue t -> InvalidValue t -> Bool)
-> Eq (InvalidValue t)
forall t. Eq t => InvalidValue t -> InvalidValue t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall t. Eq t => InvalidValue t -> InvalidValue t -> Bool
== :: InvalidValue t -> InvalidValue t -> Bool
$c/= :: forall t. Eq t => InvalidValue t -> InvalidValue t -> Bool
/= :: InvalidValue t -> InvalidValue t -> Bool
Eq, Eq (InvalidValue t)
Eq (InvalidValue t) =>
(InvalidValue t -> InvalidValue t -> Ordering)
-> (InvalidValue t -> InvalidValue t -> Bool)
-> (InvalidValue t -> InvalidValue t -> Bool)
-> (InvalidValue t -> InvalidValue t -> Bool)
-> (InvalidValue t -> InvalidValue t -> Bool)
-> (InvalidValue t -> InvalidValue t -> InvalidValue t)
-> (InvalidValue t -> InvalidValue t -> InvalidValue t)
-> Ord (InvalidValue t)
InvalidValue t -> InvalidValue t -> Bool
InvalidValue t -> InvalidValue t -> Ordering
InvalidValue t -> InvalidValue t -> InvalidValue t
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall t. Ord t => Eq (InvalidValue t)
forall t. Ord t => InvalidValue t -> InvalidValue t -> Bool
forall t. Ord t => InvalidValue t -> InvalidValue t -> Ordering
forall t.
Ord t =>
InvalidValue t -> InvalidValue t -> InvalidValue t
$ccompare :: forall t. Ord t => InvalidValue t -> InvalidValue t -> Ordering
compare :: InvalidValue t -> InvalidValue t -> Ordering
$c< :: forall t. Ord t => InvalidValue t -> InvalidValue t -> Bool
< :: InvalidValue t -> InvalidValue t -> Bool
$c<= :: forall t. Ord t => InvalidValue t -> InvalidValue t -> Bool
<= :: InvalidValue t -> InvalidValue t -> Bool
$c> :: forall t. Ord t => InvalidValue t -> InvalidValue t -> Bool
> :: InvalidValue t -> InvalidValue t -> Bool
$c>= :: forall t. Ord t => InvalidValue t -> InvalidValue t -> Bool
>= :: InvalidValue t -> InvalidValue t -> Bool
$cmax :: forall t.
Ord t =>
InvalidValue t -> InvalidValue t -> InvalidValue t
max :: InvalidValue t -> InvalidValue t -> InvalidValue t
$cmin :: forall t.
Ord t =>
InvalidValue t -> InvalidValue t -> InvalidValue t
min :: InvalidValue t -> InvalidValue t -> InvalidValue t
Ord, Int -> InvalidValue t -> ShowS
[InvalidValue t] -> ShowS
InvalidValue t -> String
(Int -> InvalidValue t -> ShowS)
-> (InvalidValue t -> String)
-> ([InvalidValue t] -> ShowS)
-> Show (InvalidValue t)
forall t. Show t => Int -> InvalidValue t -> ShowS
forall t. Show t => [InvalidValue t] -> ShowS
forall t. Show t => InvalidValue t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> InvalidValue t -> ShowS
showsPrec :: Int -> InvalidValue t -> ShowS
$cshow :: forall t. Show t => InvalidValue t -> String
show :: InvalidValue t -> String
$cshowList :: forall t. Show t => [InvalidValue t] -> ShowS
showList :: [InvalidValue t] -> ShowS
Show)

-- | Range error for various data types.
data RangeError t = RangeError
  { forall t. RangeError t -> [(t, t)]
reRange :: [(t, t)]
  -- ^ Allowed range (sum of acceptable ranges).
  , forall t. RangeError t -> t
reValue :: t
  -- ^ Provided value which is not in above range.
  }
  deriving (RangeError t -> RangeError t -> Bool
(RangeError t -> RangeError t -> Bool)
-> (RangeError t -> RangeError t -> Bool) -> Eq (RangeError t)
forall t. Eq t => RangeError t -> RangeError t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall t. Eq t => RangeError t -> RangeError t -> Bool
== :: RangeError t -> RangeError t -> Bool
$c/= :: forall t. Eq t => RangeError t -> RangeError t -> Bool
/= :: RangeError t -> RangeError t -> Bool
Eq, Eq (RangeError t)
Eq (RangeError t) =>
(RangeError t -> RangeError t -> Ordering)
-> (RangeError t -> RangeError t -> Bool)
-> (RangeError t -> RangeError t -> Bool)
-> (RangeError t -> RangeError t -> Bool)
-> (RangeError t -> RangeError t -> Bool)
-> (RangeError t -> RangeError t -> RangeError t)
-> (RangeError t -> RangeError t -> RangeError t)
-> Ord (RangeError t)
RangeError t -> RangeError t -> Bool
RangeError t -> RangeError t -> Ordering
RangeError t -> RangeError t -> RangeError t
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall t. Ord t => Eq (RangeError t)
forall t. Ord t => RangeError t -> RangeError t -> Bool
forall t. Ord t => RangeError t -> RangeError t -> Ordering
forall t. Ord t => RangeError t -> RangeError t -> RangeError t
$ccompare :: forall t. Ord t => RangeError t -> RangeError t -> Ordering
compare :: RangeError t -> RangeError t -> Ordering
$c< :: forall t. Ord t => RangeError t -> RangeError t -> Bool
< :: RangeError t -> RangeError t -> Bool
$c<= :: forall t. Ord t => RangeError t -> RangeError t -> Bool
<= :: RangeError t -> RangeError t -> Bool
$c> :: forall t. Ord t => RangeError t -> RangeError t -> Bool
> :: RangeError t -> RangeError t -> Bool
$c>= :: forall t. Ord t => RangeError t -> RangeError t -> Bool
>= :: RangeError t -> RangeError t -> Bool
$cmax :: forall t. Ord t => RangeError t -> RangeError t -> RangeError t
max :: RangeError t -> RangeError t -> RangeError t
$cmin :: forall t. Ord t => RangeError t -> RangeError t -> RangeError t
min :: RangeError t -> RangeError t -> RangeError t
Ord, Int -> RangeError t -> ShowS
[RangeError t] -> ShowS
RangeError t -> String
(Int -> RangeError t -> ShowS)
-> (RangeError t -> String)
-> ([RangeError t] -> ShowS)
-> Show (RangeError t)
forall t. Show t => Int -> RangeError t -> ShowS
forall t. Show t => [RangeError t] -> ShowS
forall t. Show t => RangeError t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> RangeError t -> ShowS
showsPrec :: Int -> RangeError t -> ShowS
$cshow :: forall t. Show t => RangeError t -> String
show :: RangeError t -> String
$cshowList :: forall t. Show t => [RangeError t] -> ShowS
showList :: [RangeError t] -> ShowS
Show)

-- | Array dimenstion mismatch error.
data ArrayDimensionMismatch = ArrayDimensionMismatch
  { ArrayDimensionMismatch -> Int
arrDimExpected :: !Int
  -- ^ Dimension expected by the library.
  , ArrayDimensionMismatch -> Int
arrDimDelivered :: !Int
  -- ^ Dimension provided by the database.
  }
  deriving (ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
(ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool)
-> (ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool)
-> Eq ArrayDimensionMismatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
== :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
$c/= :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
/= :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
Eq, Eq ArrayDimensionMismatch
Eq ArrayDimensionMismatch =>
(ArrayDimensionMismatch -> ArrayDimensionMismatch -> Ordering)
-> (ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool)
-> (ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool)
-> (ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool)
-> (ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool)
-> (ArrayDimensionMismatch
    -> ArrayDimensionMismatch -> ArrayDimensionMismatch)
-> (ArrayDimensionMismatch
    -> ArrayDimensionMismatch -> ArrayDimensionMismatch)
-> Ord ArrayDimensionMismatch
ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
ArrayDimensionMismatch -> ArrayDimensionMismatch -> Ordering
ArrayDimensionMismatch
-> ArrayDimensionMismatch -> ArrayDimensionMismatch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Ordering
compare :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Ordering
$c< :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
< :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
$c<= :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
<= :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
$c> :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
> :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
$c>= :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
>= :: ArrayDimensionMismatch -> ArrayDimensionMismatch -> Bool
$cmax :: ArrayDimensionMismatch
-> ArrayDimensionMismatch -> ArrayDimensionMismatch
max :: ArrayDimensionMismatch
-> ArrayDimensionMismatch -> ArrayDimensionMismatch
$cmin :: ArrayDimensionMismatch
-> ArrayDimensionMismatch -> ArrayDimensionMismatch
min :: ArrayDimensionMismatch
-> ArrayDimensionMismatch -> ArrayDimensionMismatch
Ord, Int -> ArrayDimensionMismatch -> ShowS
[ArrayDimensionMismatch] -> ShowS
ArrayDimensionMismatch -> String
(Int -> ArrayDimensionMismatch -> ShowS)
-> (ArrayDimensionMismatch -> String)
-> ([ArrayDimensionMismatch] -> ShowS)
-> Show ArrayDimensionMismatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArrayDimensionMismatch -> ShowS
showsPrec :: Int -> ArrayDimensionMismatch -> ShowS
$cshow :: ArrayDimensionMismatch -> String
show :: ArrayDimensionMismatch -> String
$cshowList :: [ArrayDimensionMismatch] -> ShowS
showList :: [ArrayDimensionMismatch] -> ShowS
Show)

-- | Row length mismatch error.
data RowLengthMismatch = RowLengthMismatch
  { RowLengthMismatch -> Int
lengthExpected :: !Int
  -- ^ Length expected by the library.
  , RowLengthMismatch -> Int
lengthDelivered :: !Int
  -- ^ Length delivered by the database.
  }
  deriving (RowLengthMismatch -> RowLengthMismatch -> Bool
(RowLengthMismatch -> RowLengthMismatch -> Bool)
-> (RowLengthMismatch -> RowLengthMismatch -> Bool)
-> Eq RowLengthMismatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RowLengthMismatch -> RowLengthMismatch -> Bool
== :: RowLengthMismatch -> RowLengthMismatch -> Bool
$c/= :: RowLengthMismatch -> RowLengthMismatch -> Bool
/= :: RowLengthMismatch -> RowLengthMismatch -> Bool
Eq, Eq RowLengthMismatch
Eq RowLengthMismatch =>
(RowLengthMismatch -> RowLengthMismatch -> Ordering)
-> (RowLengthMismatch -> RowLengthMismatch -> Bool)
-> (RowLengthMismatch -> RowLengthMismatch -> Bool)
-> (RowLengthMismatch -> RowLengthMismatch -> Bool)
-> (RowLengthMismatch -> RowLengthMismatch -> Bool)
-> (RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch)
-> (RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch)
-> Ord RowLengthMismatch
RowLengthMismatch -> RowLengthMismatch -> Bool
RowLengthMismatch -> RowLengthMismatch -> Ordering
RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RowLengthMismatch -> RowLengthMismatch -> Ordering
compare :: RowLengthMismatch -> RowLengthMismatch -> Ordering
$c< :: RowLengthMismatch -> RowLengthMismatch -> Bool
< :: RowLengthMismatch -> RowLengthMismatch -> Bool
$c<= :: RowLengthMismatch -> RowLengthMismatch -> Bool
<= :: RowLengthMismatch -> RowLengthMismatch -> Bool
$c> :: RowLengthMismatch -> RowLengthMismatch -> Bool
> :: RowLengthMismatch -> RowLengthMismatch -> Bool
$c>= :: RowLengthMismatch -> RowLengthMismatch -> Bool
>= :: RowLengthMismatch -> RowLengthMismatch -> Bool
$cmax :: RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch
max :: RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch
$cmin :: RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch
min :: RowLengthMismatch -> RowLengthMismatch -> RowLengthMismatch
Ord, Int -> RowLengthMismatch -> ShowS
[RowLengthMismatch] -> ShowS
RowLengthMismatch -> String
(Int -> RowLengthMismatch -> ShowS)
-> (RowLengthMismatch -> String)
-> ([RowLengthMismatch] -> ShowS)
-> Show RowLengthMismatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RowLengthMismatch -> ShowS
showsPrec :: Int -> RowLengthMismatch -> ShowS
$cshow :: RowLengthMismatch -> String
show :: RowLengthMismatch -> String
$cshowList :: [RowLengthMismatch] -> ShowS
showList :: [RowLengthMismatch] -> ShowS
Show)

-- | Affected/returned rows mismatch error.
data AffectedRowsMismatch = AffectedRowsMismatch
  { AffectedRowsMismatch -> [(Int, Int)]
rowsExpected :: ![(Int, Int)]
  -- ^ Number of rows expected by the library, expressed as sum of acceptable
  -- ranges, eg. [(1,2), (5,10)] means that it would accept 1, 2, 5, 6, 7, 8,
  -- 9 or 10 affected/returned rows.
  , AffectedRowsMismatch -> Int
rowsDelivered :: !Int
  -- ^ Number of affected/returned rows by the database.
  }
  deriving (AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
(AffectedRowsMismatch -> AffectedRowsMismatch -> Bool)
-> (AffectedRowsMismatch -> AffectedRowsMismatch -> Bool)
-> Eq AffectedRowsMismatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
== :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
$c/= :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
/= :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
Eq, Eq AffectedRowsMismatch
Eq AffectedRowsMismatch =>
(AffectedRowsMismatch -> AffectedRowsMismatch -> Ordering)
-> (AffectedRowsMismatch -> AffectedRowsMismatch -> Bool)
-> (AffectedRowsMismatch -> AffectedRowsMismatch -> Bool)
-> (AffectedRowsMismatch -> AffectedRowsMismatch -> Bool)
-> (AffectedRowsMismatch -> AffectedRowsMismatch -> Bool)
-> (AffectedRowsMismatch
    -> AffectedRowsMismatch -> AffectedRowsMismatch)
-> (AffectedRowsMismatch
    -> AffectedRowsMismatch -> AffectedRowsMismatch)
-> Ord AffectedRowsMismatch
AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
AffectedRowsMismatch -> AffectedRowsMismatch -> Ordering
AffectedRowsMismatch
-> AffectedRowsMismatch -> AffectedRowsMismatch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: AffectedRowsMismatch -> AffectedRowsMismatch -> Ordering
compare :: AffectedRowsMismatch -> AffectedRowsMismatch -> Ordering
$c< :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
< :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
$c<= :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
<= :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
$c> :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
> :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
$c>= :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
>= :: AffectedRowsMismatch -> AffectedRowsMismatch -> Bool
$cmax :: AffectedRowsMismatch
-> AffectedRowsMismatch -> AffectedRowsMismatch
max :: AffectedRowsMismatch
-> AffectedRowsMismatch -> AffectedRowsMismatch
$cmin :: AffectedRowsMismatch
-> AffectedRowsMismatch -> AffectedRowsMismatch
min :: AffectedRowsMismatch
-> AffectedRowsMismatch -> AffectedRowsMismatch
Ord, Int -> AffectedRowsMismatch -> ShowS
[AffectedRowsMismatch] -> ShowS
AffectedRowsMismatch -> String
(Int -> AffectedRowsMismatch -> ShowS)
-> (AffectedRowsMismatch -> String)
-> ([AffectedRowsMismatch] -> ShowS)
-> Show AffectedRowsMismatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AffectedRowsMismatch -> ShowS
showsPrec :: Int -> AffectedRowsMismatch -> ShowS
$cshow :: AffectedRowsMismatch -> String
show :: AffectedRowsMismatch -> String
$cshowList :: [AffectedRowsMismatch] -> ShowS
showList :: [AffectedRowsMismatch] -> ShowS
Show)

instance E.Exception DetailedQueryError
instance E.Exception QueryError
instance E.Exception HPQTypesError
instance E.Exception LibPQError
instance E.Exception ConversionError
instance E.Exception ArrayItemError
instance (Show t, Typeable t) => E.Exception (InvalidValue t)
instance (Show t, Typeable t) => E.Exception (RangeError t)
instance E.Exception ArrayDimensionMismatch
instance E.Exception RowLengthMismatch
instance E.Exception AffectedRowsMismatch