__zone_symbol__currentTask错误 [英] __zone_symbol__currentTask Error

查看:1301
本文介绍了__zone_symbol__currentTask错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:


{__ zone_symbol_currentTask:{type:microTask,state:notScheduled ,source:Promise.then,zone:angular,cancelFn:null,runCount:0}}

{"__zone_symbol_currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0}}

这就是代码:

async getNewData(id: number, path: string, howMany: number) {
    let fileManagement: FileManagement = new FileManagement();
    let result: any = null;
    switch (id) {
        case 0:
            alert("pfad: " + path);
            await fileManagement.readFile(path + "Tasks/", "task_" + howMany + ".tsk").then((text) => {
                alert("text: " + text);
                result = JSON.parse(text);
                alert("ganz fertig");
            }).catch((error)=>{
                alert("nein, error: " + JSON.stringify(error));
            });
        default:
            result = JSON.parse(this.getDataFromComponent(id, howMany, path));
        //wenn komponenten aufgerufen werden sollen zum generieren
    }
    return result;
}
constructor(public navCtrl: NavController, private tts: TextToSpeech, navParams: NavParams) {
    this.path = navParams.get('path'); //PFAD DES ÜBUNGSORDNERS HIER ÜBERGEBEN
    this.newData.getNewData(0, this.path, this.fileCounter).then((data) => {
      this.buffer = data;
      this.fileCounter++;
      this.nextChoice(0);
    }).catch((error) => {
      alert(JSON.stringify(error)); //here the error is thrown
    });
  }

您能告诉我为什么会这样,以及如何解决这个问题?我很感激任何答案!

Could you please tell me why that is and how I can fix it? I would appreciate any answer!

推荐答案

我应该注意,任何人都不可能在此代码中看到原始错误,因为它部分取决于外部依赖性。相反,此回答会尝试为您提供一种方法来确定您收到不完整错误消息的原因以及如何识别实际错误消息。我希望有所帮助!

I should note that it is unlikely for anyone to see the original error in this code since it in part depends on external dependencies. Instead, this "answer" attempts to provide you with a way to identify why you are getting an incomplete error message and how you can identify the actual error message. I hope that helps!

您遇到的基本问题正被隐藏两个事实:

The underlying issue you are encountering is being hidden by two facts:


  1. __ zone_symbol_currentTask 是一个由Angular插入到Error对象的属性。

  2. JSON.stringify 不输出Error对象自己的属性(默认情况下)

  1. The __zone_symbol_currentTask is a property inserted into the Error object by Angular.
  2. JSON.stringify does not output the Error object's own properties (by default)

因此,您在JSONified输出中看到的唯一错误属性是Angular引入的奇怪的属性。

As a result, the only error property you are seeing in the JSONified output is that strange-looking property introduced by Angular.

要记录基础错误详细信息,您可以尝试以下操作:

To log your underlying error detail, you might try the following:

JSON.stringify(错误,Object.getOwnPropertyNames(错误))

虽然这通常不会如果它确实困扰你,你可以删除Angular插入的属性:

Though this would not generally be recommended, you could remove the property inserted by Angular if it really bothers you:

删除错误.__ zone_symbol__currentTask

另请参阅:不可能使用JSON.stringify字符串化错误?

这篇关于__zone_symbol__currentTask错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆