Skip to content

Commit

Permalink
Remove unnecessary try / catch
Browse files Browse the repository at this point in the history
The code is adequately guarded against reference errors etc., so it
shouldn't error even in browsers without support for the performance
API.

If ther were an issue, we still would have had some unhandled errors,
because the addEventListener callback wouldn't be covered by the try /
catch.

Simpler just to remove it.
  • Loading branch information
richardTowers committed Jan 9, 2025
1 parent 31608d9 commit 7d2d051
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@
}
}

try {
if (window.performance && performance.getEntriesByType) {
// Because the `nextHopProtocol` isn't immediately available - it seems to need
// a request to be made before it's populated - we need to wait for the
// `DOMContentReady` event before we can see what the HTTP version is.
if (document.readyState === 'complete') {
if (window.performance && performance.getEntriesByType) {
// Because the `nextHopProtocol` isn't immediately available - it seems to need
// a request to be made before it's populated - we need to wait for the
// `DOMContentReady` event before we can see what the HTTP version is.
if (document.readyState === 'complete') {
measureCustomData()
} else {
window.addEventListener('load', function() {
measureCustomData()
} else {
window.addEventListener('load', function() {
measureCustomData()
})
}
})
}
} catch (e) {
console.error('Error in LUX reporting the HTTP protocol (%s):', window.location, e)
}
})()

0 comments on commit 7d2d051

Please sign in to comment.