Bug 1854749 [wpt PR 42116] - Set original error as context when raising a different error, a=testonly

Automatic update from web-platform-tests
Set original error as context when raising a different error

--

wpt-commits: 5f0fba3215492e89b9021bf3bfb9dac63e8fd7c9
wpt-pr: 42116
This commit is contained in:
James Graham 2023-09-27 12:16:32 +00:00 коммит произвёл moz-wptsync-bot
Родитель e46c33b893
Коммит bc6475082c
6 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -342,7 +342,7 @@ class WebDriverBrowser(Browser):
except OSError as e:
if e.errno == errno.ENOENT:
raise OSError(
"WebDriver executable not found: %s" % self.webdriver_binary)
"WebDriver executable not found: %s" % self.webdriver_binary) from e
raise
self._output_handler.after_process_start(self._proc.pid)

Просмотреть файл

@ -733,8 +733,8 @@ class CallbackHandler:
self.logger.debug("Got async callback: %s" % result[1])
try:
callback = self.callbacks[command]
except KeyError:
raise ValueError("Unknown callback type %r" % result[1])
except KeyError as e:
raise ValueError("Unknown callback type %r" % result[1]) from e
return callback(url, payload)
def process_complete(self, url, payload):
@ -747,8 +747,8 @@ class CallbackHandler:
self.logger.debug(f"Got action: {action}")
try:
action_handler = self.actions[action]
except KeyError:
raise ValueError(f"Unknown action {action}")
except KeyError as e:
raise ValueError(f"Unknown action {action}") from e
try:
with ActionContext(self.logger, self.protocol, payload.get("context")):
result = action_handler(payload)

Просмотреть файл

@ -33,8 +33,8 @@ def _read_line(io_queue, deadline=None, encoding=None, errors="strict", raise_cr
raise CrashError()
if raise_crash_leak and line.startswith(b"#LEAK"):
raise LeakError()
except Empty:
raise TimeoutError()
except Empty as e:
raise TimeoutError() from e
return line.decode(encoding, errors) if encoding else line

Просмотреть файл

@ -626,8 +626,8 @@ class MarionetteSetPermissionProtocolPart(SetPermissionProtocolPart):
}
try:
self.marionette._send_message("WebDriver:SetPermission", body)
except errors.UnsupportedOperationException:
raise NotImplementedError("set_permission not yet implemented")
except errors.UnsupportedOperationException as e:
raise NotImplementedError("set_permission not yet implemented") from e
class MarionettePrintProtocolPart(PrintProtocolPart):

Просмотреть файл

@ -27,9 +27,9 @@ def _read_line(io_queue, deadline=None, encoding=None, errors="strict", raise_cr
line = io_queue.get(True, deadline - current_time if deadline else None)
if raise_crash and line.startswith(b"#CRASHED"):
raise CrashError()
except Empty:
except Empty as e:
logger.debug(f"got empty line with {time() - deadline} remaining")
raise TimeoutError()
raise TimeoutError() from e
return line.decode(encoding, errors) if encoding else line

Просмотреть файл

@ -63,8 +63,8 @@ class BaseState:
raise AttributeError
try:
return self._data[self._index][key]
except KeyError:
raise AttributeError
except KeyError as e:
raise AttributeError from e
def __contains__(self, key):
return key in self._data[self._index]