diff --git a/src/main.lisp b/src/main.lisp index 2a22cff..5a169ce 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -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) diff --git a/src/pgsql/queries.lisp b/src/pgsql/queries.lisp index 115f41c..a37f164 100644 --- a/src/pgsql/queries.lisp +++ b/src/pgsql/queries.lisp @@ -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;"))))