ui_init: Properly call reject with an error, not an xhr.

If the spectator registration call fails, properly log the error and
call `reject` with an error object, not the xhr that `channel.post`
calls its error callback with.

This does nothing to address the UI question of what to do should this
request fail.
This commit is contained in:
Alex Vandiver 2023-05-19 15:02:36 +00:00 committed by Tim Abbott
parent b312a86ada
commit 18578cc5da
1 changed files with 13 additions and 2 deletions

View File

@ -731,8 +731,19 @@ $(async () => {
}),
client_gravatar: false,
};
const {result, msg, ...state} = await new Promise((success, error) => {
channel.post({url: "/json/register", data, success, error});
const {result, msg, ...state} = await new Promise((resolve, reject) => {
channel.post({
url: "/json/register",
data,
resolve,
error(xhr) {
blueslip.error("Spectator failed to register", {
status: xhr.status,
bodt: xhr.responseText,
});
reject(new Error("Spectator failed to register"));
},
});
});
Object.assign(page_params, state);
}