On 08/10/13 14:40, Erik Bernhardson wrote:
> A reviewer should be able to
> know if the error conditions are properly handled by looking at the new
> code, not by looking up all the function calls to see what they can
> possibly return.

This is why the recommended pattern for Status objects is to return a
Status object unconditionally, i.e. both on success and on failure --
so that the developer of the calling code is reminded that the
function can fail, and so that a lack of error-handling will be explicit:

$status = $this->foo();
$result = $status->value; // reviewer alert
$result->bar();

Instead of implicit:

$result = $this->foo();
$result->bar();

php-option seems to be following the same pattern, except with a
throwing accessor for $status->value.

I gather the main thing you don't like about Status is that it
contains message formatting. It seems to me that if you added a
throwing accessor to the Status class, and didn't use its message
formatting functions, it would more or less fit your needs.

-- Tim Starling



_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to