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

wrap key transform fun in try/catch with Class:Exception clause #231

Open
wants to merge 1 commit into
base: develop-3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/bitcask.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1993,10 +1993,21 @@ expiry_merge([File | Files], LiveKeyDir, KT, Acc0) ->
end,
expiry_merge(Files, LiveKeyDir, KT, Acc).

get_key_transform(KT)
get_key_transform(KT) ->
TransformFun = key_transform_fun(KT),
fun(Key) ->
try
TransformFun(Key)
catch
Class:Exception ->
{key_tx_error, {Key, {Class, Exception}}}
end
end.

key_transform_fun(KT)
when is_function(KT) ->
KT;
get_key_transform(_State) ->
key_transform_fun(_State) ->
fun kt_id/1.

-ifdef(TEST).
Expand Down