Improve error handling.
This commit is contained in:
parent
ed33aca596
commit
16bd475be2
2 changed files with 58 additions and 33 deletions
|
@ -23,10 +23,10 @@ window.onload = async function(){
|
|||
element.innerHTML = marked.parse(markDown);
|
||||
}
|
||||
// Build a journal list
|
||||
if (locationHref.searchParams.get('item')) {
|
||||
itemsList = await openJson(node)
|
||||
if (itemsList && locationHref.searchParams.get('item')) {
|
||||
node = locationHref.searchParams.get('node')
|
||||
pubsub = locationHref.searchParams.get('pubsub')
|
||||
itemsList = await openJson(node)
|
||||
let elementDiv = document.createElement('div');
|
||||
elementDiv.id = 'journal';
|
||||
let elementH3 = document.createElement('h3');
|
||||
|
@ -74,10 +74,14 @@ window.onload = async function(){
|
|||
for (let xmppLink of document.querySelectorAll('a[href^="xmpp:"]')) {
|
||||
xmppUri = new URL(xmppLink);
|
||||
let parameters = xmppUri.search.split(';');
|
||||
let node = parameters.find(parameter => parameter.startsWith('node=')).split('=')[1];
|
||||
let item = parameters.find(parameter => parameter.startsWith('item=')).split('=')[1];
|
||||
let pubsub = xmppUri.pathname;
|
||||
xmppLink.href = `atom?pubsub=${pubsub}&node=${node}&item=${item}`
|
||||
try {
|
||||
let node = parameters.find(parameter => parameter.startsWith('node=')).split('=')[1];
|
||||
let item = parameters.find(parameter => parameter.startsWith('item=')).split('=')[1];
|
||||
let pubsub = xmppUri.pathname;
|
||||
xmppLink.href = `atom?pubsub=${pubsub}&node=${node}&item=${item}`
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
}
|
||||
}
|
||||
// Display a selection of suggested software.
|
||||
const selection = {
|
||||
|
@ -173,13 +177,6 @@ async function openJson(nodeId) {
|
|||
return json;
|
||||
})
|
||||
.catch(err => {
|
||||
throw new Error('Error: ' + err);
|
||||
console.warn(err);
|
||||
})
|
||||
}
|
||||
|
||||
function parseXmppPubsubLink(link) {
|
||||
const parts = link.split(';');
|
||||
const node = parts.find(part => part.startsWith('node=')).split('=')[1];
|
||||
const item = parts.find(part => part.startsWith('item=')).split('=')[1];
|
||||
return { node, item };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue