Handle a down stream server
Committed daef4e
--- a/webint_live/templates/stream.html
+++ b/webint_live/templates/stream.html
<script>
document.addEventListener('DOMContentLoaded', ev => {
fetch('/stream-stats')
- .then(response => response.text())
+ .then(response => {
+ if (!response.ok)
+ throw new Error('stream stats server down')
+ return response.text()
+ })
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(data => {
const streams = data.getElementsByTagName('stream')
document.querySelector('#streamduration').innerHTML = Math.round(ms / 1000 / 60)
}
})
+ .catch(error => {
+ console.error('Error:', error.message)
+ })
})
</script>