log error stack instead of throwing in watcher

This commit is contained in:
Evan You 2016-06-01 15:56:53 -04:00
parent fd6a31febf
commit 76b4b8d281

View File

@ -8,16 +8,12 @@ import {
remove,
isObject,
parsePath,
nextTick,
_Set as Set
} from '../util/index'
let uid = 0
let prevTarget
/* istanbul ignore next */
const defaultErrorHandler = e => nextTick(() => { throw e })
/**
* A watcher parses an expression, collects dependencies,
* and fires callback when the expression value changes.
@ -102,8 +98,12 @@ export default class Watcher {
this.vm
)
}
// throw the error on next tick so that it doesn't break the whole app
;(config.errorHandler || defaultErrorHandler)(e, this.vm)
/* istanbul ignore else */
if (config.errorHandler) {
config.errorHandler.call(null, e, this.vm)
} else {
warn(e.stack)
}
}
// return old value when evaluation fails so the current UI is preserved
value = this.value