show actual error when graphData fails
The original reason for the catch-all message was users with bad data such as decimal intervals, but those get automatically coerced these days. The common case should now be invalid search strings, which we can show verbatim.
This commit is contained in:
parent
57c53632a6
commit
4ac9ad1407
@ -172,7 +172,6 @@ statistics-elapsed-time-years = { $amount }y
|
||||
|
||||
##
|
||||
|
||||
statistics-error-fetching = Error searching - please check your search is correct, or use the Check Database feature.
|
||||
statistics-average-for-days-studied = Average for days studied
|
||||
statistics-total = Total
|
||||
statistics-days-studied = Days studied
|
||||
|
@ -287,11 +287,14 @@ def handle_post(path: str) -> Response:
|
||||
return flask.make_response("Collection not open", HTTPStatus.NOT_FOUND)
|
||||
|
||||
if path in post_handlers:
|
||||
if data := post_handlers[path]():
|
||||
response = flask.make_response(data)
|
||||
response.headers["Content-Type"] = "application/binary"
|
||||
else:
|
||||
response = flask.make_response("", HTTPStatus.NO_CONTENT)
|
||||
try:
|
||||
if data := post_handlers[path]():
|
||||
response = flask.make_response(data)
|
||||
response.headers["Content-Type"] = "application/binary"
|
||||
else:
|
||||
response = flask.make_response("", HTTPStatus.NO_CONTENT)
|
||||
except Exception as e:
|
||||
return flask.make_response(str(e), HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||
else:
|
||||
response = flask.make_response(
|
||||
f"Unhandled post to {path}",
|
||||
|
@ -37,7 +37,7 @@
|
||||
revlogRange = daysToRevlogRange(days);
|
||||
} catch (e) {
|
||||
sourceData = null;
|
||||
alert(i18n.tr(i18n.TR.STATISTICS_ERROR_FETCHING));
|
||||
alert(e);
|
||||
}
|
||||
active = false;
|
||||
};
|
||||
|
@ -7,7 +7,8 @@ export async function postRequest(path: string, body: string): Promise<Uint8Arra
|
||||
body,
|
||||
});
|
||||
if (!resp.ok) {
|
||||
throw Error(`unexpected reply: ${resp.statusText}`);
|
||||
const body = await resp.text();
|
||||
throw Error(`${resp.status}: ${body}`);
|
||||
}
|
||||
// get returned bytes
|
||||
const respBlob = await resp.blob();
|
||||
|
Loading…
Reference in New Issue
Block a user