From 9c0213016bf631ec67a61a15e1e5772597e4a0c2 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 6 Jan 2021 16:03:54 +0000 Subject: [PATCH] Handle login-required errors a bit better --- src/api.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index 53b9697..1c7963e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -540,11 +540,17 @@ export default { getConfiguration(): Promise { return fetch(window.config.url.configuration).then(response => { if (!response.ok) { - throw new Error('Network response was not ok'); + throw new Error('Network request failed'); } return response.json(); }).then((response): DynmapConfigurationResponse => { + if(response.error === 'login-required') { + throw new Error("Login required"); + } else if (response.error) { + throw new Error(response.error); + } + return { config: buildServerConfig(response), messages: buildMessagesConfig(response),