refactor: rework error handling to simplifiy command implementation and provide better back traces

This commit is contained in:
CJ van den Berg 2024-06-26 23:29:39 +02:00
parent 21b604f4d6
commit 032982c1e8
26 changed files with 821 additions and 785 deletions

View file

@ -103,8 +103,8 @@ fn append(self: *Self, json: []const u8) !void {
pub fn listen(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
if (try m.match(.{ "M", tp.more })) return;
var buf: [4096]u8 = undefined;
const json = m.to_json(&buf) catch |e| return tp.exit_error(e);
self.append(json) catch |e| return tp.exit_error(e);
const json = m.to_json(&buf) catch |e| return tp.exit_error(e, @errorReturnTrace());
self.append(json) catch |e| return tp.exit_error(e, @errorReturnTrace());
}
pub fn receive(_: *Self, _: tp.pid_ref, _: tp.message) error{Exit}!bool {