~subsetpark/erasmus

a1d5f13fc784f9ef77a75be1541a139d32e87bd2 — Zach Smith 3 months ago 31d8db0
Use catch directly when handling errors
1 files changed, 4 insertions(+), 4 deletions(-)

M src/main.zig
M src/main.zig => src/main.zig +4 -4
@@ 245,7 245,7 @@ pub fn main() !void {
                .error_slice = undefined,
            };
            defer brackets.brackets.deinit();
            if (findBracketedStrings(note_body.items, &brackets)) {} else |err| switch (err) {
            findBracketedStrings(note_body.items, &brackets) catch |err| switch (err) {
                RuntimeError.BracketInBrackets => {
                    std.debug.print("Found improperly nested brackets: {s}.\n", .{
                        brackets.error_slice,


@@ 255,7 255,7 @@ pub fn main() !void {
                else => {
                    return err;
                },
            }
            };
            // References padding.
            if (brackets.brackets.items.len > 0) {
                try new_note_body.append('\n');


@@ 268,12 268,12 @@ pub fn main() !void {
                };
                defer escaped.escaped.deinit();

                if (escape(phrase, &escaped)) {} else |err| {
                escape(phrase, &escaped) catch |err| {
                    std.debug.print("Found illegal character in brackets: `{s}`\n", .{
                        escaped.error_slice,
                    });
                    std.os.exit(1);
                }
                };
                try appendRef(&new_note_body, escaped.escaped.items, allocator);
            }
            // Optional debugging.