Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong matching of sqlite3 error codes. #5

Open
malotte opened this issue Jan 31, 2013 · 0 comments
Open

Wrong matching of sqlite3 error codes. #5

malotte opened this issue Jan 31, 2013 · 0 comments

Comments

@malotte
Copy link
Contributor

malotte commented Jan 31, 2013

kvdb_sqlite3.erl, or other modules using functions in this module, might crash since there is a faulty presumption that error codes returned from sqlite3 has the format {error, Error}, for example in kvdb_sqlite3.erl, line 231 (function put):
{error,_} = Error ->
Error
Investigation into sqlite3 shows that there is another possible error format, {error, integer(), string()}:
%% @type sqlite_error() = {'error', integer(), string()} | {'error', any()}.
%% @type sql_result() = sql_non_query_result() | [{columns, [string()]} | {rows, [tuple()]} | sqlite_error()].

A solution could be wrapping all calls to sqlite3 in a function somewhat like this:
%% Need to convert error result
sqlite_call(M,F,Args) ->
case M:F(Args) of
{error, Int, String} -> {error, {Int, String}};
Other -> Other
end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant