【问题标题】:Sentry for VueJS 2 - captureException Error - change name?VueJS 2 的哨兵 - captureException 错误 - 更改名称?
【发布时间】:2021-10-30 00:55:15
【问题描述】:

有什么方法可以将“错误”更改为“设置错误”之类的内容,然后描述出现问题的内容?

async allBays() {
      try {
        let response = await mapService.getBaysList();
        let bayList = response.data.data;
        if (bayList) {
          this.bays = bayList.map((list) => {
            return {
              value: { id: list.id, name: list.state },
              text: list.state,
            };
          });
        }
      } catch (e) {
        Sentry.captureException(new Error("Could not load bays"), {
          tags: {
            section: "Farm Setup",
          },
        });
      }
    },

如下所示:

感谢您的帮助,文档太长了,我找不到确切的答案

【问题讨论】:

    标签: vue.js exception error-handling sentry


    【解决方案1】:

    您可以扩展 JavaScript Error 类。

    class SetupError extends Error {
      constructor(message) {
        super(message)
        this.name = 'Setup Error'
      }
    }
    

    async allBays() {
          try {
            let response = await mapService.getBaysList();
            let bayList = response.data.data;
            if (bayList) {
              this.bays = bayList.map((list) => {
                return {
                  value: { id: list.id, name: list.state },
                  text: list.state,
                };
              });
            }
          } catch (e) {
            Sentry.captureException(new SetupError("Could not load bays"), {
              tags: {
                section: "Farm Setup",
              },
            });
          }
        },
    

    【讨论】:

    • 谢谢我试试看!
    猜你喜欢
    • 2014-06-11
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多