4 ms·
You should consider using options error payloads. Saw an article on zig.news Benefit is if you don't want the payload, the code to generate the payload gets c
by throwawaymaths 3y ago
You should consider using options error payloads. Saw an article on zig.news
Benefit is if you don't want the payload, the code to generate the payload gets compiled out.
- skybrian 3y agoThis seems to be it: https://zig.news/ityonemo/sneaky-error-payloads-1aka https://zig.news/ityonemo/sneaky-error-payloads-1aka It looks like it would be useful, but relies on a naming convention? Hopefully everyone picks the same field names.
- throwawaymaths 3y agoOr, read the docs on the function you're calling?
- skybrian 3y agoI was thinking more about what happens if you’re combining already-written code that uses different naming conventions, or even different types. Suppose you get an error in one format and want to pass it on in a different format? Writing a converter probably isn’t so hard, but it’s tedious, like having multiple kinds of strings. But it’s probably too soon to worry about that when Zig doesn’t have a package manager yet.
- dns_snek 3y ago> But it’s probably too soon to worry about that when Zig doesn’t have a package manager yet. Just fyi in case you haven't seen the news, It launched with 0.11 release a couple of days ago.
- throwawaymaths 3y agoAgreed. Probably tedious. But straightforward, unlike say, multiple inheritance, and, likely to be rare.
- throwawaymaths 3y agoThe article was updated: https://zig.news/ityonemo/error-payloads-updated-367m https://zig.news/ityonemo/error-payloads-updated-367m