lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Handling db errors (postgressql)

Open romanesko opened this issue 8 years ago • 1 comments

If i throw error in postgres stored procedure like raise exception 'something' using errcode='OF001'; — i get only the message

lps_1 | 2016/05/12 09:13:41 [notice] 21#0: *181 [lua] app.lua:22: /usr/local/share/lua/5.1/lapis/db/postgres.lua:81: select res from test_me() res;
lps_1 | ERROR: something, client: 192.168.99.1, server: , request: "GET /api/test/me HTTP/1.1", host: "192.168.99.100:8080"

Can I get db error code?

romanesko avatar May 12 '16 09:05 romanesko

I just added db error codes to pgmoon but they aren't exposed in lapis right now. The way lapis handles db error is by calling error which isn't flexible for cases where you might expect an error (eg. handling a unique key insertion failure).

I need to come up with an interface for accessing the error codes that doesn't break existing API and has no serious performance implications.

leafo avatar Jul 23 '16 02:07 leafo