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",
|
"name": "townsquare",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"description": "Blood on the Clocktower Town Square",
|
"description": "Blood on the Clocktower Town Square",
|
||||||
"author": "Steffen Baumgart",
|
"author": "Steffen Baumgart",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -116,7 +116,13 @@ export default {
|
||||||
if (file && file.size) {
|
if (file && file.size) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener("load", () => {
|
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);
|
reader.readAsText(file);
|
||||||
}
|
}
|
||||||
|
@ -130,8 +136,12 @@ export default {
|
||||||
async handleURL(url) {
|
async handleURL(url) {
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
if (res && res.json) {
|
if (res && res.json) {
|
||||||
|
try {
|
||||||
const script = await res.json();
|
const script = await res.json();
|
||||||
this.parseRoles(script);
|
this.parseRoles(script);
|
||||||
|
} catch (e) {
|
||||||
|
alert("Error loading custom script: " + e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
parseRoles(roles) {
|
parseRoles(roles) {
|
||||||
|
|
Loading…
Reference in New Issue