kopia lustrzana https://github.com/ertdfgcvb/play.core
44 wiersze
939 B
HTML
44 wiersze
939 B
HTML
<!DOCTYPE html>
|
|
<html lang="en" >
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Promise chain</title>
|
|
</head>
|
|
<body>
|
|
<pre>Console output only</pre>
|
|
<script>
|
|
addEventListener('error', function(error) {
|
|
console.log("------------")
|
|
console.log(error)
|
|
}, false)
|
|
|
|
|
|
addEventListener('unhandledrejection', function(event) {
|
|
console.log(event.promise) // [object Promise] - the promise that generated the error
|
|
console.log(event.reason) // Error: Whoops! - the unhandled error object
|
|
})
|
|
|
|
</script>
|
|
<script type="module">
|
|
|
|
// Test to check how errors are 'catched' in async / Promises.
|
|
// https://javascript.info/async-await
|
|
// http://thecodebarbarian.com/async-await-error-handling-in-javascript.html
|
|
|
|
|
|
function b() {
|
|
|
|
c( // <---
|
|
function c() {
|
|
setTimeout(() => resolve("b"), 1000)
|
|
}
|
|
|
|
}
|
|
|
|
console.log("a")
|
|
//b().then(res => console.log(res))
|
|
console.log("c")
|
|
|
|
</script>
|
|
</body>
|
|
</html> |