I finally hit a scenario where i need dynamic error messages to be shown to an end user for binary decoder i am busy with. This naturally led me to discover the diagnostics pattern, which I see has been discussed a few times on this forum. The idea made a lot of sense and I looked at some examples but they all seemed a bit.. complicated? Why not just capture text if the goal is the end user? Did an implementation that makes sense to me:
https://codeberg.org/acudac/utils-zig/src/branch/main/src/Diagnostics.zig
matklad July 10, 2026, 3:30pm 3
matklad July 10, 2026, 3:45pm 5
Oh, you also want writeAll rather than write. In general, _ = usually is a mistake.
Chaz July 10, 2026, 4:02pm 6
I think an app would want to probably capture text directly but a library would want to provide the ingredients instead. That’s my reasoning anyway.
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.