Added extra function to return a map with error information

This commit is contained in:
Maas-Maarten Zeeman
2022-05-22 22:19:30 +02:00
parent 71ab29c724
commit 135715bf0a
3 changed files with 61 additions and 2 deletions

View File

@@ -19,7 +19,10 @@
%% higher-level export
-export([
open/1, close/1,
open/1,
close/1,
error_info/1,
%% db connection functions
set_update_hook/2,
@@ -136,6 +139,13 @@ open(Filename) ->
close(#esqlite3{db=Connection}) ->
esqlite3_nif:close(Connection).
%% @doc Return a description of the last occurred error.
-spec error_info(Connection) -> ErrorMsg
when Connection :: esqlite3(),
ErrorMsg :: undefined | binary().
error_info(#esqlite3{db=Connection}) ->
esqlite3_nif:error_info(Connection).
%% @doc Subscribe to database notifications. When rows are inserted deleted
%% or updates, the process will receive messages:

View File

@@ -22,6 +22,7 @@
-export([
open/1,
close/1,
error_info/1,
set_update_hook/2,
@@ -89,6 +90,15 @@ open(_Filename) ->
close(_Db) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Get an error messages for the last occurred error.
%%
-spec error_info(Connection) -> ErrorMsg
when Connection :: esqlite3(),
ErrorMsg :: map().
error_info(_Db) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Set an update hook
%%
-spec set_update_hook(Connection, Pid) -> Result