Bug 1858298 - Improve error message when an action isn't implemented, r=Sasha
commit684d646a8457d8381a6d8cb0b4a9c07c53ac6491
authorJames Graham <james@hoppipolla.co.uk>
Thu, 19 Oct 2023 10:39:34 +0000 (19 10:39 +0000)
committerJames Graham <james@hoppipolla.co.uk>
Thu, 19 Oct 2023 10:39:34 +0000 (19 10:39 +0000)
tree14d5ded85de168d000b13cf366f47078c858e05f
parent0ab70b9491aae765d59df82c40b798dc800bc35e
Bug 1858298 - Improve error message when an action isn't implemented, r=Sasha

Actions typically work by looking for the implementation in an
executor-specific Protocol object. Since different executors implement
different things, these protocols are composed of many ProtocolParts,
which are accessed just through normal attribute lookup.

The problem is that this means that when we don't implement a
ProtocolPart in a given protocol we throw an AttributeError rather
than e.g. NotImplementedError. That means the harness doesn't deal
with the exception gracefully and ends up printing a trackback.

There are a few ways we could handle this:
* Ensure that each executor has at least a no-op implementation of
each ProtocolPart.
* Check on/before use of each ProtocolPart that it exists.
* Make failed attribute access on Protocol objects throw
NotImplementedError.
* Stop using attribute lookup syntax for accessing ProtocolParts.

All of these seem either quite verbose, or break normal Python object
protocols.

As a quick fix, if we get an AttributeError when trying to run an
action handler, and that error was thrown on the Protocol object,
re-raise it as a NotImplementedError.

This isn't a perfect fix, but it's relatively contained and fixes the
immediate problem without requiring larger refactors.

Differential Revision: https://phabricator.services.mozilla.com/D190940
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py