Skip to content

Postgresql exceptions #353

Description

@jcristovao

Hello,

Perhaps I'm missing something obvious, but I somewhat was expecting withStmt' to return a SqlError, not a user error:

user error (Postgresql.withStmt': bad result status FatalError (("PGRES_FATAL_ERROR","ERROR: duplicate key value violates...

I guess this as to do with using fail which then gets turned into a UserError/IOError by with.

Would there be any way to bracket an insert just on SqlError, or do I have to bracket into the far more general IOError?

Thanks

Activity

  1. snoyberg commented on Jan 16, 2015

    @snoyberg
    Member

    I'm not able to work on the codebase right now (getting ready to travel), but this seems like a reasonable request. If someone sends a PR, I'll be happy to merge. Otherwise, I probably won't be able to get to this for another week or two.

  2. added a commit that references this issue on Jan 16, 2015
    08da36e
  3. jcristovao commented on Jan 16, 2015

    @jcristovao
    ContributorAuthor

    So, I've took a stab at this, let me know what you think.
    Thanks!

  4. snoyberg commented on Feb 10, 2015

    @snoyberg
    Member

    This looks good to me, sorry for the delayed review. Unless someone has an objection, I'd merge this in.

  5. jcristovao commented on Feb 11, 2015

    @jcristovao
    ContributorAuthor

    Thanks!

  6. akurilin commented on Feb 21, 2015

    @akurilin

    Would this by any chance expose the underlying Postgres error code or whatever it is translated to by the library being used to execute the query? e.g. PostgreSQL.Simple exposes a type for constraint violation errors. It's useful to pattern-match against for insertions and updates, when you want to perform the operation first, and handle the exception, as opposed to the less reliable check & insert approach.

  7. jcristovao commented on Feb 21, 2015

    @jcristovao
    ContributorAuthor

    That's precisely my use case, and why I submitted this patch ;)

  8. jonkri commented on May 12, 2015

    @jonkri

    +1

  9. gregwebs commented on May 12, 2015

    @gregwebs
    Member

    @snoyberg do you know what the status of this issue is?

  10. snoyberg commented on May 12, 2015

    @snoyberg
    Member

    IIRC, I'm waiting for @jcristovao to send a PR with his change. Though if people are more eager to see this go out the door, anyone else could theoretically take @jcristovao's commit and send it as a PR him/herself.

  11. jcristovao commented on May 12, 2015

    @jcristovao
    ContributorAuthor

    Ok, I forgot I did not actually submited this as a PR, my bad.
    Will take care of this tomorrow

  12. jonkri commented on May 12, 2015

    @jonkri

    Thanks! :)

  13. added a commit that references this issue on May 28, 2015
  14. added a commit that references this issue on May 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions