Some more error handling.

This commit is contained in:
Dimitri Fontaine 2013-11-07 23:17:00 +01:00
parent 4095b74db7
commit a9d160dc32
2 changed files with 11 additions and 5 deletions

View File

@ -72,7 +72,9 @@
((condition
#'(lambda (c)
(if debug
(trivial-backtrace:print-backtrace c :verbose t)
(trivial-backtrace:print-backtrace c
:output *standard-output*
:verbose t)
(trivial-backtrace:print-condition c *standard-output*)))))
(let ((min-messages (cond (debug :debug)
(verbose :info)

View File

@ -52,16 +52,20 @@
(declare (ignore res))
(pgstate-incf state label :rows count :secs secs)))
;;;
;;; PostgreSQL queries
;;;
(defun pgsql-execute (sql &key ((:client-min-messages level)))
"Execute given SQL in current transaction"
(when level
(pomo:execute
(format nil "SET LOCAL client_min_messages TO ~a;" (symbol-name level))))
(pomo:execute sql)
(handler-case
;; execute the query, catching errors and warnings
(pgsql-execute sql)
(cl-postgres:database-error (e)
(log-message :error "~a" e))
(cl-postgres:postgresql-warning (w)
(log-message :warning "~a" w)))
(when level (pomo:execute (format nil "RESET client_min_messages;"))))