webmcp
diff libraries/mondelefant/mondelefant_native.autodoc.lua @ 397:46ba2168693a
Improved error handling in mondelefant_native.c; Fixed bug in error handling when PQsendQuery returned 0
| author | jbe |
|---|---|
| date | Thu Dec 10 17:23:51 2015 +0100 (2015-12-10) |
| parents | ae1a66bb6b7d |
| children | 0cb4bf644f1b |
line diff
1.1 --- a/libraries/mondelefant/mondelefant_native.autodoc.lua Wed Dec 09 21:16:24 2015 +0100 1.2 +++ b/libraries/mondelefant/mondelefant_native.autodoc.lua Thu Dec 10 17:23:51 2015 +0100 1.3 @@ -2,7 +2,7 @@ 1.4 --[[-- 1.5 db_handle, -- database handle, or nil in case of error 1.6 errmsg, -- error message 1.7 -errcode = -- error code 1.8 +db_error -- error object 1.9 mondelefant.connect{ 1.10 engine = "postgresql", -- no other engine is supported 1.11 conninfo = conninfo, -- string passed directly to PostgreSQL's libpq 1.12 @@ -77,21 +77,19 @@ 1.13 1.14 1.15 --[[-- 1.16 -channel, -- notification channel name 1.17 -payload, -- notification payload string 1.18 -pid = -- process ID of notifying server process 1.19 -<db_handle>:wait( 1.20 - timeout -- number of seconds to wait, 0 = do not block, nil = wait infinitely 1.21 +db_error, -- error object, or nil in case of success or timeout 1.22 +channel, -- notification channel name, or nil in case of timeout or no pending notify 1.23 +payload, -- notification payload string 1.24 +pid = -- process ID of notifying server process 1.25 +<db_handle>:try_wait( 1.26 + timeout -- number of seconds to wait, 0 = do not block, nil = wait infinitely 1.27 ) 1.28 1.29 Waits for any NOTIFY event that is being LISTENed for. One or more LISTEN commands must have been sent previously with <db_handle>:query("LISTEN channel_name"). 1.30 1.31 -Returns nil as first return value and an error message as second return value in case of error. 1.32 -Returns false as first return value and a message as second return value in case of timeout. 1.33 - 1.34 --]]-- 1.35 -- implemented in mondelefant_native.c as 1.36 --- static int mondelefant_conn_wait(lua_State *L) 1.37 +-- static int mondelefant_conn_try_wait(lua_State *L) 1.38 --//-- 1.39 1.40 1.41 @@ -196,7 +194,9 @@ 1.42 --[[-- 1.43 <db_error>:escalate() 1.44 1.45 -Causes a Lua error to be thrown. If the database connection has "error_objects" set to true, then the object is thrown itself, otherwise a string is thrown. 1.46 +Deprecated alias for error(<db_error>). 1.47 + 1.48 +Note: Previous versions converted the error object to a string unless the database connection had "error_objects" set to true. The current implementation simply calls error(...). It is deprecated to use this method, use error(...) instead. 1.49 1.50 --]]-- 1.51 -- implemented in mondelefant_native.c as 1.52 @@ -222,6 +222,43 @@ 1.53 1.54 1.55 --[[-- 1.56 +<db_error>.code -- hierarchical error code (separated by dots) in camel case 1.57 + 1.58 +An error code in camel case notation with dots to separate hierarchy levels, e.g. "IntegrityConstraintViolation.UniqueViolation". See also <db_error>:is_kind_of(...). 1.59 + 1.60 +--]]-- 1.61 +-- implemented in mondelefant_native.c as 1.62 +-- static const char *mondelefant_translate_errcode(const char *pgcode) 1.63 +--//-- 1.64 + 1.65 + 1.66 +--[[-- 1.67 +<db_error>.message -- string which summarizes the error 1.68 + 1.69 +A string consisting of a single line (without CR/LF) describing the error. For more detailed information on a particular error, additional fields may be set in the <db_error> object. Refer to the source code of the mondelefant_translate_errcode C function in mondelefant_native.c. 1.70 + 1.71 +--]]-- 1.72 +-- implemented in mondelefant_native.c 1.73 +--//-- 1.74 + 1.75 + 1.76 +--[[-- 1.77 +channel, -- notification channel name, or nil in case of timeout or no pending notify 1.78 +payload, -- notification payload string 1.79 +pid = -- process ID of notifying server process 1.80 +<db_handle>:wait( 1.81 + timeout -- number of seconds to wait, 0 = do not block, nil = wait infinitely 1.82 +) 1.83 + 1.84 +Same as "try_wait" but raises an error, if a connection error occurred. Timeouts are reported by returning nil as first argument. 1.85 + 1.86 +--]]-- 1.87 +-- implemented in mondelefant_native.c as 1.88 +-- static int mondelefant_conn_wait(lua_State *L) 1.89 +--//-- 1.90 + 1.91 + 1.92 +--[[-- 1.93 result1, -- result of first command 1.94 result2, -- result of second command 1.95 ... =