Closed gnusupport closed 5 years ago
notifications@github.com writes:
I should be able to get the erorr and not just enter debugger on something like
(pq:query *rcd-pg* "SEjnjn")
so how do I do it?
currently, your only option is to catch all emacs errors, look at the error string, and re-throw if you don't handle them. Example:
(condition-case err
(pq:query *pq* "moo")
(error
(if (string-match "^ERROR: syntax error" (cdr err))
(message "whoop whoop")
;; re-throw
(signal (car err) (cdr err))
)))
I was thinking there is some error handling option, I cannot find it. Please help. Imagine editing a table field and it should be unique, and database is raising error. I think I should be able to capture, understand error and do further programming based on that.
Originally, emacs-libpq used a custom error signal, but @marsam changed it to common emacs errors in an early patch. I'm afraid I have to reintroduce it in order to make sane handling of SQL errors possible (e.g., handing out the SQLSTATE would allow for easy and standardized classification of errors thrown by emacs-libpq).
Thank you for that example of condition-case, I can now do something usable with it. Thanks for updates to the code.
I just pushed a change that introduces a custom error signal that makes the SQLSTATE error code available. This will break the example I posted above, but is a much more reliable way to catch specific SQL errors. See the updated README for an example.
I should be able to get the database erorr programmatically and not just enter debugger on something like
so how do I do it?
I cannot find description for these optional parameters:
I was thinking there is some error handling option, I cannot find it. Please help. Imagine editing a table field and it should be unique, and database is raising error. I think I should be able to capture, understand error and do further programming based on that.