【问题标题】:How to remove unicode from Graphql error message如何从 Graphql 错误消息中删除 unicode
【发布时间】:2022-01-25 16:55:07
【问题描述】:

我尝试在我的解析器中捕获,捕获看起来像这样

catch (err: any) {
            LOG.error("Failed to get location with ID: " + args.id);
            LOG.error(err);

            throw new Error(err);
        }

当我在 graphql 中运行查询时,会出现以下错误消息

 {
  "errors": [
    {
      "message": "Error: \u001b[31m5 NOT_FOUND: Location was not found\u001b[39m",
      "locations": [
        {
          "line": 34,
          "column": 3
        }
      ],
      "path": [
        "getLocation"
      ]
    }
  ],
  "data": {
    "getLocation": null
  }

如何从错误消息中删除 \u001b[31m5?

【问题讨论】:

    标签: typescript graphql


    【解决方案1】:

    问题是控制台无法识别Typescript。

    $ npm install —dev @types/node
    

    你安装@types/node了吗?

    【讨论】:

      猜你喜欢
      • 2011-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-08-19
      • 2018-01-16
      • 2013-12-25
      • 1970-01-01
      • 1970-01-01
      • 2021-01-28
      相关资源
      最近更新 更多