fix: try-case-of rather than try-of

try-of catches only what happens within but not after
This commit is contained in:
Stefan Strigler 2023-01-23 13:57:49 +01:00
parent 965236c888
commit b7e3f9d5a6
1 changed files with 7 additions and 5 deletions

View File

@ -266,11 +266,13 @@ code_change(_OldVsn, State, _Extra) ->
%%============================================================================== %%==============================================================================
-define(PICK(ID, KEY, PID, EXPR), -define(PICK(ID, KEY, PID, EXPR),
try gproc_pool:pick_worker(ID, KEY) of try
case gproc_pool:pick_worker(ID, KEY) of
PID when is_pid(PID) -> PID when is_pid(PID) ->
EXPR; EXPR;
_ -> _ ->
?RESOURCE_ERROR(worker_not_created, "resource not created") ?RESOURCE_ERROR(worker_not_created, "resource not created")
end
catch catch
error:badarg -> error:badarg ->
?RESOURCE_ERROR(worker_not_created, "resource not created"); ?RESOURCE_ERROR(worker_not_created, "resource not created");