量角器中的defer.reject()不显示堆栈跟踪?也就是说,我不知道代码的哪一行

时间:2016-05-26 13:25:40

标签: javascript promise protractor angular-promise deferred

我使用defer.rejct()作为错误处理方法。 但是,当它抛出失败时,它没有显示堆栈跟踪。 使用promise可以很容易地在量角器中捕获异常吗?

function formatPoolRecordsGridData(row) {
var defer = protractor.promise.defer();
switch (record.poolLevelRecordType) {
    case "A":
       <do something here>
       break;
    default:
        //Error Handling
        defer.reject('There is no matched record type');
        break;
}
//There is no way to say which line of the code it is failed
        Message:
        Failed: There is no matched record type
      Stack:
        Error: Failed: There is no matched record type
            at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:101:16
            at Promise.invokeCallback_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
            at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
            at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)

1 个答案:

答案 0 :(得分:1)

错误对象只会捕获对调试有用的堆栈跟踪

拒绝只会拒绝承诺并调用相应的失败方法

拒绝错误对象,它只捕获堆栈trace.ex:

reject(new Error("There is no matched record type"));