Handle login-required errors a bit better
This commit is contained in:
parent
ae377b8a26
commit
9c0213016b
@ -540,11 +540,17 @@ export default {
|
|||||||
getConfiguration(): Promise<DynmapConfigurationResponse> {
|
getConfiguration(): Promise<DynmapConfigurationResponse> {
|
||||||
return fetch(window.config.url.configuration).then(response => {
|
return fetch(window.config.url.configuration).then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Network response was not ok');
|
throw new Error('Network request failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then((response): DynmapConfigurationResponse => {
|
}).then((response): DynmapConfigurationResponse => {
|
||||||
|
if(response.error === 'login-required') {
|
||||||
|
throw new Error("Login required");
|
||||||
|
} else if (response.error) {
|
||||||
|
throw new Error(response.error);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
config: buildServerConfig(response),
|
config: buildServerConfig(response),
|
||||||
messages: buildMessagesConfig(response),
|
messages: buildMessagesConfig(response),
|
||||||
|
Loading…
Reference in New Issue
Block a user