mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Report better errors on SQL terms decode failure
This commit is contained in:
parent
0ed638c7fb
commit
2b523030cf
@ -276,9 +276,23 @@ encode_term(Term) ->
|
||||
|
||||
decode_term(Bin) ->
|
||||
Str = binary_to_list(<<Bin/binary, ".">>),
|
||||
{ok, Tokens, _} = erl_scan:string(Str),
|
||||
{ok, Term} = erl_parse:parse_term(Tokens),
|
||||
Term.
|
||||
try
|
||||
{ok, Tokens, _} = erl_scan:string(Str),
|
||||
{ok, Term} = erl_parse:parse_term(Tokens),
|
||||
Term
|
||||
catch _:{badmatch, {error, {Line, Mod, Reason}, _}} ->
|
||||
?ERROR_MSG("Corrupted Erlang term in SQL database:~n"
|
||||
"** Scanner error: at line ~B: ~s~n"
|
||||
"** Term: ~s",
|
||||
[Line, Mod:format_error(Reason), Bin]),
|
||||
erlang:error(badarg);
|
||||
_:{badmatch, {error, {Line, Mod, Reason}}} ->
|
||||
?ERROR_MSG("Corrupted Erlang term in SQL database:~n"
|
||||
"** Parser error: at line ~B: ~s~n"
|
||||
"** Term: ~s",
|
||||
[Line, Mod:format_error(Reason), Bin]),
|
||||
erlang:error(badarg)
|
||||
end.
|
||||
|
||||
-spec sqlite_db(binary()) -> atom().
|
||||
sqlite_db(Host) ->
|
||||
|
Loading…
Reference in New Issue
Block a user