Skip to content

Commit

Permalink
fix: use try in submit instead of catching error
Browse files Browse the repository at this point in the history
There are some errdefers above, make sure they are executed
  • Loading branch information
rbino committed Feb 26, 2025
1 parent 167ee40 commit 30264e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const SubmitError = error{
TooManyRequests,
Shutdown,
OutOfMemory,
ClientInvalid,
};

// These are all comptime generated functions
Expand Down Expand Up @@ -114,6 +115,7 @@ fn get_submit_fn(comptime operation: tb_client.Operation) (fn (
error.TooManyRequests => beam.make_error_atom(env, "too_many_requests"),
error.Shutdown => beam.make_error_atom(env, "shutdown"),
error.OutOfMemory => beam.make_error_atom(env, "out_of_memory"),
error.ClientInvalid => beam.make_error_atom(env, "client_closed"),
};
}
}.submit_fn;
Expand Down Expand Up @@ -168,9 +170,7 @@ fn submit(
.status = undefined,
};

client.submit(packet) catch |err| switch (err) {
error.ClientInvalid => return beam.make_error_atom(env, "client_closed"),
};
try client.submit(packet);

return beam.make_ok_term(env, ref);
}
Expand Down

0 comments on commit 30264e6

Please sign in to comment.