Skip to content

Commit

Permalink
Improved error for ColumnTypeMismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Jan 4, 2024
1 parent 86916c1 commit f1dbdae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions beam-postgres/Database/Beam/Postgres/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ runPgRowReader conn rowIdx res fields (FromBackendRowM readRow) =
case pgErr of
Pg.ConversionFailed { Pg.errSQLType = sql
, Pg.errHaskellType = hs
, Pg.errMessage = msg } ->
pure (ColumnTypeMismatch hs sql msg)
, Pg.errMessage = msg
, Pg.errSQLField = field } ->
pure (ColumnTypeMismatch hs sql ("Conversion failed for field'" <> field <> "': " <> msg))
Pg.Incompatible { Pg.errSQLType = sql
, Pg.errHaskellType = hs
, Pg.errMessage = msg } ->
pure (ColumnTypeMismatch hs sql msg)
, Pg.errMessage = msg
, Pg.errSQLField = field } ->
pure (ColumnTypeMismatch hs sql ("Incompatible field: '" <> field <> "': " <> msg))
Pg.UnexpectedNull {} ->
pure ColumnUnexpectedNull
in pure (Left (BeamRowReadError (Just (fromIntegral curCol)) err))
Expand Down

0 comments on commit f1dbdae

Please sign in to comment.