273
error as value
also Result, Go error
Return the error or throw it. Do not do both, and do not swallow either.
What is error as value?
Some languages return a Result or an error value. Others throw. A boundary picks one. An empty catch, a logged-and-ignored error, and a null that means both “missing” and “broken” hide different failures. A panic or an exception is for a programmer bug. A user-facing failure is a value you handle.
Why does error as value matter when vibe coding?
The draft catches Exception, logs it, and returns null. The caller treats null as not-found and tells the user the row is gone. The database was down.
How do you do error as value?
Return a typed error for expected failures. Crash, loudly, on a broken invariant. Do not catch the base exception. Do not map every failure to null or to 200.
How do you ask a model for error as value?
Return errors from (function) as values the caller must handle. Do not catch the base exception. Do not return null for both not-found and a broken dependency. Not-found is (type). A down dependency is (type).
What goes wrong with error as value?
Wrapping every error in a new one until the original code and the stack are gone. The log says “failed” and nothing else.