#Error Throwing Philosophy

1 messages · Page 1 of 1 (latest)

strong flint
#

As I’ve been getting into zig I’ve been writing functions such that if they could return null they throw an error instead. Is this correct? Or will it just be a nuisance later on

light radish
#

Depends

#

Think about what the "default" way to handle it should be

#

If it's "pass it up to the caller" then an error is correct, because try is the "default" error handling strategy

#

If it's "choose a different value", "assert" or "store the null" then it should be an optional

strong flint
#

Rad, thank you!