Use WebError, not RuntimeError, to indicate error

Several problems with using RuntimeError to signal error here:

- It dumps a rather unhelpful webpage at the user.
- The exception backtrace on Tahoe console is not quite necessary here.
- It really is not a runtime error: it is just an expected failure.
- But mainly, testing for RuntimeError is harder.
This commit is contained in:
Sajith Sasidharan 2020-07-09 10:01:13 -04:00
parent f9e864c51c
commit 54248f334e

View File

@ -25,6 +25,7 @@ from allmydata.web.common import (
render_time,
MultiFormatResource,
SlotsSequenceElement,
WebError,
)
from allmydata.interfaces import (
@ -1171,9 +1172,7 @@ class Status(MultiFormatResource):
try:
stype, count_s = path.split("-")
except ValueError:
raise RuntimeError(
"no - in '{}'".format(path)
)
raise WebError("no '-' in '{}'".format(path))
count = int(count_s)
if stype == "up":
for s in itertools.chain(h.list_all_upload_statuses(),