error as value
Represent expected failures explicitly in a function’s result.
Use this when Callers cannot tell not-found from validation failure or an unavailable dependency.
without the term
“This function returns null for not found, for invalid input, and when the database is down, so callers can't tell what happened. Can you make the failure cases clear?”
with the term · How do you ask a model for error as value?
Return explicit result variants for these expected failures. Test each caller’s recovery behavior while preserving unexpected errors for diagnosis.
What is error as value?
Functions return expected failures, such as not found or invalid, as typed results the caller must handle. Exceptions are kept for the unexpected.
Why does error as value matter when vibe coding?
A generic null or catch-all response hides the recovery decision.
How do you do error as value?
Define a small result type and require callers to handle its relevant cases.
What goes wrong with error as value?
Converting every unexpected exception into an ordinary empty result.