ensure content parsable before showing it

pull/1/head
yann300 8 years ago
parent a8a0f8322e
commit 405994af0d
  1. 12
      src/app/tabs/compile-tab.js

@ -383,11 +383,19 @@ function compileTab (container, appAPI, appEvents, opts) {
return ret return ret
} }
}) })
node = yo`<div>${treeView.render(JSON.parse(details[x]))}</div>` if (details[x] !== '') {
try {
node = yo`<div>${treeView.render(JSON.parse(details[x]))}</div>` // catch in case the parsing fails.
} catch (e) {
node = yo`<div>Unable to display "${x}": ${e.message}</div>`
}
} else {
node = yo`<div> - </div>`
}
} else { } else {
node = yo`<div>${JSON.stringify(details[x], null, 4)}</div>` node = yo`<div>${JSON.stringify(details[x], null, 4)}</div>`
} }
value.appendChild(node) if (node) value.appendChild(node)
return value return value
} }

Loading…
Cancel
Save