report uncaught errors
This commit is contained in:
parent
e4a16d3bf4
commit
264741f2f5
3 changed files with 29 additions and 6 deletions
|
|
@ -58,7 +58,10 @@ function updateState(stream, value, error) {
|
|||
if (recovered === HALT) return
|
||||
updateValues(stream, recovered, undefined)
|
||||
}
|
||||
catch (e) {updateValues(stream, undefined, e)}
|
||||
catch (e) {
|
||||
updateValues(stream, undefined, e)
|
||||
reportUncaughtError(stream, e)
|
||||
}
|
||||
}
|
||||
else updateValues(stream, value, error)
|
||||
stream._state.changed = true
|
||||
|
|
@ -81,6 +84,7 @@ function updateDependency(stream, mustSync) {
|
|||
}
|
||||
catch (e) {
|
||||
updateState(stream, undefined, e)
|
||||
reportUncaughtError(stream, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +100,13 @@ function finalize(stream) {
|
|||
stream._state.changed = false
|
||||
for (var id in stream._state.deps) stream._state.deps[id]._state.changed = false
|
||||
}
|
||||
function reportUncaughtError(stream, e) {
|
||||
if (Object.keys(stream._state.deps).length === 0) {
|
||||
setTimeout(function() {
|
||||
if (Object.keys(stream._state.deps).length === 0) console.error(e)
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
||||
function run(fn) {
|
||||
var self = createStream(), stream = this
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ o.spec("stream", function() {
|
|||
o("error.map works", function() {
|
||||
var stream = Stream.stream(1)
|
||||
var mappedFromError = stream.error.map(function(value) {
|
||||
return "from" + value.message
|
||||
if (value) return "from" + value.message
|
||||
})
|
||||
|
||||
o(mappedFromError()).equals(undefined)
|
||||
|
|
@ -382,7 +382,7 @@ o.spec("stream", function() {
|
|||
var a = Stream.stream(1)
|
||||
var b = Stream.combine(function(a) {throw new Error("error from b")}, [a])
|
||||
var c = Stream.combine(function(a) {throw new Error("error from c")}, [a])
|
||||
var d = Stream.combine(function(a, b) {return 2}, [a, b])
|
||||
var d = Stream.combine(function(b, c) {return 2}, [b, c])
|
||||
|
||||
o(d()).equals(undefined)
|
||||
o(d.error().message).equals("error from b")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue