|
|
|
|
|
by Huggernaut
1676 days ago
|
|
I agree. I would be extremely surprised and look for refactoring opportunities if I came across a function that returned a success case that was expected to be used in combination with an error value. If anyone has an example of this being a pattern used somewhere that they think is good I'd love for them to share it. |
|
Probably bad example off the top of my head: You're returning say a "User" which has a user_id, name, and a list of recent purchases.
If the function errors out on the recent purchases, the caller may prefer that it still gets back a "User" object with the other information filled in, and then an "error" also set so the caller knows the information isn't complete.