Skip to content

Commit

Permalink
proper error json error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthäus Szturc authored and Matthäus Szturc committed Feb 1, 2021
1 parent 133f668 commit bb73678
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,22 @@ export default class MyPlugin extends Plugin {
rawText = rawText.replace("[[", '"[[');
rawText = rawText.replace("]]", ']]"');
}

parameters = JSON.parse(rawText);
console.log(parameters);
parameters = JSON.parse(rawText);

} catch (e) {
console.log("Query was not valid JSON: " + e.message);
el.createEl("h2", { text: "PDF Parameters invalid: " + e.message });
}

//Remove old Representation
const root = node.parentElement;
root.removeChild(node);

//Create PDF Node
const child = new PDFRenderNode(root, this.app, parameters);
ctx.addChild(child);
//Create PDF Node
if(parameters !== null) {
const child = new PDFRenderNode(root, this.app, parameters);
ctx.addChild(child);
}

}
});
}
Expand Down

0 comments on commit bb73678

Please sign in to comment.