Skip to content

Should this library catch postgresql-simple's SqlErrors and make them available via PgNamedError? #27

@jhrcek

Description

@jhrcek

I'd like to start a discussion about ${subj}

The fact that functions like query from postgresql-simple operate in IO monad, whereas the functions in this library use mtl's MonadError (e.g. queryNamed) which makes it a bit harder to handle SqlErrors (thrown by postgresql-simple via throwIO) when using wrappers from this library.

I recently used MonadBaseControl + lifted-base to be able to get access to SqlError thrown by a query and rethrow it in our application monad which also uses MonadError.

Would it be a good idea to take advantage of the fact that potgresql-functions run in IO
and modify the existing PgNamedError by adding new constructor like this?

data PgNameError = 
   ...
   SqlError Database.PostgreSQL.Simple.SqlError

... and then wrapping calls to postgresql-simple query functions in some exception catching code and rethrowing them inside MonadError?

Advantage: In that case we could work with SqlErrors directly via our App's MonadError instance without resorting to its MonadBaseControl IO instance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions