Просмотр исходного кода

log error stack instead of throwing in watcher

Evan You 10 лет назад
Родитель
Сommit
76b4b8d281
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      src/core/observer/watcher.js

+ 6 - 6
src/core/observer/watcher.js

@@ -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