module Hasql.Engine.Errors where
import Hasql.Comms.Recv qualified
import Hasql.Comms.ResultDecoder qualified
import Hasql.Comms.Roundtrip qualified
import Hasql.Comms.RowReader qualified
import Hasql.Platform.Prelude
import TextBuilder qualified
data ConnectionError
=
NetworkingConnectionError
Text
|
AuthenticationConnectionError
Text
|
CompatibilityConnectionError
Text
|
OtherConnectionError
Text
deriving stock (Int -> ConnectionError -> ShowS
[ConnectionError] -> ShowS
ConnectionError -> String
(Int -> ConnectionError -> ShowS)
-> (ConnectionError -> String)
-> ([ConnectionError] -> ShowS)
-> Show ConnectionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnectionError -> ShowS
showsPrec :: Int -> ConnectionError -> ShowS
$cshow :: ConnectionError -> String
show :: ConnectionError -> String
$cshowList :: [ConnectionError] -> ShowS
showList :: [ConnectionError] -> ShowS
Show, ConnectionError -> ConnectionError -> Bool
(ConnectionError -> ConnectionError -> Bool)
-> (ConnectionError -> ConnectionError -> Bool)
-> Eq ConnectionError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnectionError -> ConnectionError -> Bool
== :: ConnectionError -> ConnectionError -> Bool
$c/= :: ConnectionError -> ConnectionError -> Bool
/= :: ConnectionError -> ConnectionError -> Bool
Eq)
data SessionError
=
StatementSessionError
Int
Int
Text
[Text]
Bool
StatementError
|
ScriptSessionError
Text
ServerError
|
ConnectionSessionError
Text
|
MissingTypesSessionError
(HashSet (Maybe Text, Text))
|
DriverSessionError
Text
deriving stock (Int -> SessionError -> ShowS
[SessionError] -> ShowS
SessionError -> String
(Int -> SessionError -> ShowS)
-> (SessionError -> String)
-> ([SessionError] -> ShowS)
-> Show SessionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SessionError -> ShowS
showsPrec :: Int -> SessionError -> ShowS
$cshow :: SessionError -> String
show :: SessionError -> String
$cshowList :: [SessionError] -> ShowS
showList :: [SessionError] -> ShowS
Show, SessionError -> SessionError -> Bool
(SessionError -> SessionError -> Bool)
-> (SessionError -> SessionError -> Bool) -> Eq SessionError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SessionError -> SessionError -> Bool
== :: SessionError -> SessionError -> Bool
$c/= :: SessionError -> SessionError -> Bool
/= :: SessionError -> SessionError -> Bool
Eq)
data StatementError
=
ServerStatementError ServerError
|
UnexpectedRowCountStatementError
Int
Int
Int
|
UnexpectedColumnCountStatementError
Int
Int
|
UnexpectedColumnTypeStatementError
Int
Word32
Word32
|
RowStatementError
Int
RowError
|
UnexpectedResultStatementError
Text
deriving stock (Int -> StatementError -> ShowS
[StatementError] -> ShowS
StatementError -> String
(Int -> StatementError -> ShowS)
-> (StatementError -> String)
-> ([StatementError] -> ShowS)
-> Show StatementError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StatementError -> ShowS
showsPrec :: Int -> StatementError -> ShowS
$cshow :: StatementError -> String
show :: StatementError -> String
$cshowList :: [StatementError] -> ShowS
showList :: [StatementError] -> ShowS
Show, StatementError -> StatementError -> Bool
(StatementError -> StatementError -> Bool)
-> (StatementError -> StatementError -> Bool) -> Eq StatementError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StatementError -> StatementError -> Bool
== :: StatementError -> StatementError -> Bool
$c/= :: StatementError -> StatementError -> Bool
/= :: StatementError -> StatementError -> Bool
Eq)
data ServerError
= ServerError
Text
Text
(Maybe Text)
(Maybe Text)
(Maybe Int)
deriving stock (Int -> ServerError -> ShowS
[ServerError] -> ShowS
ServerError -> String
(Int -> ServerError -> ShowS)
-> (ServerError -> String)
-> ([ServerError] -> ShowS)
-> Show ServerError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ServerError -> ShowS
showsPrec :: Int -> ServerError -> ShowS
$cshow :: ServerError -> String
show :: ServerError -> String
$cshowList :: [ServerError] -> ShowS
showList :: [ServerError] -> ShowS
Show, ServerError -> ServerError -> Bool
(ServerError -> ServerError -> Bool)
-> (ServerError -> ServerError -> Bool) -> Eq ServerError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ServerError -> ServerError -> Bool
== :: ServerError -> ServerError -> Bool
$c/= :: ServerError -> ServerError -> Bool
/= :: ServerError -> ServerError -> Bool
Eq)
data RowError
=
CellRowError
Int
Word32
CellError
|
RefinementRowError
Text
deriving stock (Int -> RowError -> ShowS
[RowError] -> ShowS
RowError -> String
(Int -> RowError -> ShowS)
-> (RowError -> String) -> ([RowError] -> ShowS) -> Show RowError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RowError -> ShowS
showsPrec :: Int -> RowError -> ShowS
$cshow :: RowError -> String
show :: RowError -> String
$cshowList :: [RowError] -> ShowS
showList :: [RowError] -> ShowS
Show, RowError -> RowError -> Bool
(RowError -> RowError -> Bool)
-> (RowError -> RowError -> Bool) -> Eq RowError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RowError -> RowError -> Bool
== :: RowError -> RowError -> Bool
$c/= :: RowError -> RowError -> Bool
/= :: RowError -> RowError -> Bool
Eq)
data CellError
=
UnexpectedNullCellError
|
DeserializationCellError
Text
deriving stock (Int -> CellError -> ShowS
[CellError] -> ShowS
CellError -> String
(Int -> CellError -> ShowS)
-> (CellError -> String)
-> ([CellError] -> ShowS)
-> Show CellError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CellError -> ShowS
showsPrec :: Int -> CellError -> ShowS
$cshow :: CellError -> String
show :: CellError -> String
$cshowList :: [CellError] -> ShowS
showList :: [CellError] -> ShowS
Show, CellError -> CellError -> Bool
(CellError -> CellError -> Bool)
-> (CellError -> CellError -> Bool) -> Eq CellError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CellError -> CellError -> Bool
== :: CellError -> CellError -> Bool
$c/= :: CellError -> CellError -> Bool
/= :: CellError -> CellError -> Bool
Eq)
fromRoundtripError :: Hasql.Comms.Roundtrip.Error context -> SessionError
fromRoundtripError :: forall context. Error context -> SessionError
fromRoundtripError = \case
Hasql.Comms.Roundtrip.ClientError context
_context Maybe ByteString
details ->
Text -> SessionError
ConnectionSessionError (Text -> (ByteString -> Text) -> Maybe ByteString -> Text
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
"" ByteString -> Text
decodeUtf8Lenient Maybe ByteString
details)
Hasql.Comms.Roundtrip.ServerError Error context
recvError ->
Error (Maybe (Int, Int, ByteString, [Text], Bool)) -> SessionError
fromRecvError (Maybe (Int, Int, ByteString, [Text], Bool)
forall a. Maybe a
Nothing Maybe (Int, Int, ByteString, [Text], Bool)
-> Error context
-> Error (Maybe (Int, Int, ByteString, [Text], Bool))
forall a b. a -> Error b -> Error a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Error context
recvError)
fromRecvError :: Hasql.Comms.Recv.Error (Maybe (Int, Int, ByteString, [Text], Bool)) -> SessionError
fromRecvError :: Error (Maybe (Int, Int, ByteString, [Text], Bool)) -> SessionError
fromRecvError = \case
Hasql.Comms.Recv.ResultError Maybe (Int, Int, ByteString, [Text], Bool)
location Int
_resultOffset Error
resultError ->
case Maybe (Int, Int, ByteString, [Text], Bool)
location of
Maybe (Int, Int, ByteString, [Text], Bool)
Nothing ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Unexpected error outside of statement context. ",
TextBuilder
"This indicates a bug in Hasql or the server misbehaving. ",
TextBuilder
"Error: ",
String -> TextBuilder
TextBuilder.string (Error -> String
forall a. Show a => a -> String
show Error
resultError)
]
Just (Int
totalStatements, Int
statementIndex, ByteString
sql, [Text]
parameters, Bool
prepared) ->
Int
-> Int -> Text -> [Text] -> Bool -> StatementError -> SessionError
StatementSessionError
Int
totalStatements
Int
statementIndex
(ByteString -> Text
decodeUtf8Lenient ByteString
sql)
[Text]
parameters
Bool
prepared
(Error -> StatementError
fromStatementResultError Error
resultError)
Hasql.Comms.Recv.NoResultsError Maybe (Int, Int, ByteString, [Text], Bool)
location Maybe ByteString
details ->
case Maybe (Int, Int, ByteString, [Text], Bool)
location of
Maybe (Int, Int, ByteString, [Text], Bool)
Nothing ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Unexpectedly got no results outside of statement context. ",
TextBuilder
"This indicates a bug in Hasql or the server misbehaving. ",
TextBuilder
"Details: ",
String -> TextBuilder
TextBuilder.string (Maybe ByteString -> String
forall a. Show a => a -> String
show Maybe ByteString
details)
]
Just (Int
totalStatements, Int
statementIndex, ByteString
sql, [Text]
parameters, Bool
prepared) ->
Int
-> Int -> Text -> [Text] -> Bool -> StatementError -> SessionError
StatementSessionError
Int
totalStatements
Int
statementIndex
(ByteString -> Text
decodeUtf8Lenient ByteString
sql)
[Text]
parameters
Bool
prepared
(Int -> Int -> Int -> StatementError
UnexpectedRowCountStatementError Int
1 Int
1 Int
0)
Hasql.Comms.Recv.TooManyResultsError Maybe (Int, Int, ByteString, [Text], Bool)
location Int
actual ->
case Maybe (Int, Int, ByteString, [Text], Bool)
location of
Maybe (Int, Int, ByteString, [Text], Bool)
Nothing ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Unexpectedly got too many results outside of statement context. ",
TextBuilder
"This indicates a bug in Hasql or the server misbehaving. ",
TextBuilder
"Amount: ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
actual
]
Just (Int
totalStatements, Int
statementIndex, ByteString
sql, [Text]
parameters, Bool
prepared) ->
Int
-> Int -> Text -> [Text] -> Bool -> StatementError -> SessionError
StatementSessionError
Int
totalStatements
Int
statementIndex
(ByteString -> Text
decodeUtf8Lenient ByteString
sql)
[Text]
parameters
Bool
prepared
(Int -> Int -> Int -> StatementError
UnexpectedRowCountStatementError Int
1 Int
1 Int
actual)
fromStatementResultError :: Hasql.Comms.ResultDecoder.Error -> StatementError
fromStatementResultError :: Error -> StatementError
fromStatementResultError = \case
Hasql.Comms.ResultDecoder.ServerError ByteString
code ByteString
message Maybe ByteString
detail Maybe ByteString
hint Maybe Int
position ->
ServerError -> StatementError
ServerStatementError
( Text
-> Text -> Maybe Text -> Maybe Text -> Maybe Int -> ServerError
ServerError
(ByteString -> Text
decodeUtf8Lenient ByteString
code)
(ByteString -> Text
decodeUtf8Lenient ByteString
message)
((ByteString -> Text) -> Maybe ByteString -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
decodeUtf8Lenient Maybe ByteString
detail)
((ByteString -> Text) -> Maybe ByteString -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
decodeUtf8Lenient Maybe ByteString
hint)
Maybe Int
position
)
Hasql.Comms.ResultDecoder.UnexpectedResult Text
msg ->
Text -> StatementError
UnexpectedResultStatementError Text
msg
Hasql.Comms.ResultDecoder.UnexpectedRowCount Int
actual ->
Int -> Int -> Int -> StatementError
UnexpectedRowCountStatementError Int
1 Int
1 Int
actual
Hasql.Comms.ResultDecoder.UnexpectedColumnCount Int
expected Int
actual ->
Int -> Int -> StatementError
UnexpectedColumnCountStatementError Int
expected Int
actual
Hasql.Comms.ResultDecoder.DecoderTypeMismatch Int
colIdx Word32
expectedOid Word32
actualOid ->
Int -> Word32 -> Word32 -> StatementError
UnexpectedColumnTypeStatementError
Int
colIdx
Word32
expectedOid
Word32
actualOid
Hasql.Comms.ResultDecoder.RowError Int
rowIndex Error
rowError ->
case Error
rowError of
Hasql.Comms.RowReader.CellError Int
column Word32
oid CellError
cellErr ->
Int -> RowError -> StatementError
RowStatementError
Int
rowIndex
( Int -> Word32 -> CellError -> RowError
CellRowError
Int
column
Word32
oid
( case CellError
cellErr of
Hasql.Comms.RowReader.DecodingCellError Text
msg -> Text -> CellError
DeserializationCellError Text
msg
CellError
Hasql.Comms.RowReader.UnexpectedNullCellError -> CellError
UnexpectedNullCellError
)
)
Hasql.Comms.RowReader.RefinementError Text
msg ->
Int -> RowError -> StatementError
RowStatementError
Int
rowIndex
(Text -> RowError
RefinementRowError Text
msg)
fromRecvErrorInScript :: ByteString -> Hasql.Comms.Recv.Error (Maybe ByteString) -> SessionError
fromRecvErrorInScript :: ByteString -> Error (Maybe ByteString) -> SessionError
fromRecvErrorInScript ByteString
scriptSql = \case
Hasql.Comms.Recv.ResultError Maybe ByteString
_ Int
_ Error
resultError ->
case Error
resultError of
Hasql.Comms.ResultDecoder.ServerError ByteString
code ByteString
message Maybe ByteString
detail Maybe ByteString
hint Maybe Int
position ->
Text -> ServerError -> SessionError
ScriptSessionError
(ByteString -> Text
decodeUtf8Lenient ByteString
scriptSql)
( Text
-> Text -> Maybe Text -> Maybe Text -> Maybe Int -> ServerError
ServerError
(ByteString -> Text
decodeUtf8Lenient ByteString
code)
(ByteString -> Text
decodeUtf8Lenient ByteString
message)
((ByteString -> Text) -> Maybe ByteString -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
decodeUtf8Lenient Maybe ByteString
detail)
((ByteString -> Text) -> Maybe ByteString -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
decodeUtf8Lenient Maybe ByteString
hint)
Maybe Int
position
)
Hasql.Comms.ResultDecoder.UnexpectedResult Text
msg ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Unexpected result in script: ",
Text -> TextBuilder
TextBuilder.text Text
msg
]
Hasql.Comms.ResultDecoder.UnexpectedRowCount Int
actual ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Unexpected amount of rows in script: ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
actual
]
Hasql.Comms.ResultDecoder.UnexpectedColumnCount Int
expected Int
actual ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Unexpected amount of columns in script: expected ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
expected,
TextBuilder
", got ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
actual
]
Hasql.Comms.ResultDecoder.DecoderTypeMismatch Int
colIdx Word32
expectedOid Word32
actualOid ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Decoder type mismatch in script: expected OID ",
String -> TextBuilder
TextBuilder.string (Word32 -> String
forall a. Show a => a -> String
show Word32
expectedOid),
TextBuilder
" at column ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
colIdx,
TextBuilder
", got ",
String -> TextBuilder
TextBuilder.string (Word32 -> String
forall a. Show a => a -> String
show Word32
actualOid)
]
Hasql.Comms.ResultDecoder.RowError Int
rowIndex Error
rowError ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Row error in script at row ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
rowIndex,
TextBuilder
": ",
String -> TextBuilder
TextBuilder.string (Error -> String
forall a. Show a => a -> String
show Error
rowError)
]
Hasql.Comms.Recv.NoResultsError Maybe ByteString
_ Maybe ByteString
details ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Got no results in script.",
TextBuilder
" This indicates a bug in Hasql or the server misbehaving.",
Maybe ByteString
details
Maybe ByteString
-> (Maybe ByteString -> Maybe ByteString) -> Maybe ByteString
forall a b. a -> (a -> b) -> b
& (ByteString -> Bool) -> Maybe ByteString -> Maybe ByteString
forall a. (a -> Bool) -> Maybe a -> Maybe a
forall (f :: * -> *) a. Filterable f => (a -> Bool) -> f a -> f a
filter (ByteString -> ByteString -> Bool
forall a. Eq a => a -> a -> Bool
/= ByteString
"")
Maybe ByteString
-> (Maybe ByteString -> TextBuilder) -> TextBuilder
forall a b. a -> (a -> b) -> b
& (ByteString -> TextBuilder) -> Maybe ByteString -> TextBuilder
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (TextBuilder -> TextBuilder -> TextBuilder
forall a. Monoid a => a -> a -> a
mappend TextBuilder
" Details: " (TextBuilder -> TextBuilder)
-> (ByteString -> TextBuilder) -> ByteString -> TextBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> TextBuilder
TextBuilder.text (Text -> TextBuilder)
-> (ByteString -> Text) -> ByteString -> TextBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ByteString -> Text
decodeUtf8Lenient)
]
Hasql.Comms.Recv.TooManyResultsError Maybe ByteString
_ Int
actual ->
(Text -> SessionError
DriverSessionError (Text -> SessionError)
-> ([TextBuilder] -> Text) -> [TextBuilder] -> SessionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TextBuilder -> Text
TextBuilder.toText (TextBuilder -> Text)
-> ([TextBuilder] -> TextBuilder) -> [TextBuilder] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [TextBuilder] -> TextBuilder
forall a. Monoid a => [a] -> a
mconcat)
[ TextBuilder
"Got too many results in script. ",
TextBuilder
"This indicates a bug in Hasql or the server misbehaving. ",
TextBuilder
"Amount: ",
Int -> TextBuilder
forall a. Integral a => a -> TextBuilder
TextBuilder.decimal Int
actual
]