mirror of https://github.com/bra1n/townsquare.git
add error message when provided JSON is invalid
This commit is contained in:
parent
b158230fce
commit
300066a551
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "townsquare",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "Blood on the Clocktower Town Square",
|
||||
"author": "Steffen Baumgart",
|
||||
"scripts": {
|
||||
|
|
|
@ -116,7 +116,13 @@ export default {
|
|||
if (file && file.size) {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener("load", () => {
|
||||
this.parseRoles(JSON.parse(reader.result));
|
||||
try {
|
||||
const roles = JSON.parse(reader.result);
|
||||
this.parseRoles(roles);
|
||||
} catch (e) {
|
||||
alert("Error reading custom script: " + e.message);
|
||||
}
|
||||
this.$refs.upload.value = "";
|
||||
});
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
@ -130,8 +136,12 @@ export default {
|
|||
async handleURL(url) {
|
||||
const res = await fetch(url);
|
||||
if (res && res.json) {
|
||||
const script = await res.json();
|
||||
this.parseRoles(script);
|
||||
try {
|
||||
const script = await res.json();
|
||||
this.parseRoles(script);
|
||||
} catch (e) {
|
||||
alert("Error loading custom script: " + e.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
parseRoles(roles) {
|
||||
|
|
Loading…
Reference in New Issue