Michal Kubiak
Michal Kubiak

Reputation: 57

Sentry for VueJS 2 - captureException Error - change name?

is there any way of change the 'Error' to something like 'Setup Error' followed by the description of something that went wrong?

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",
          },
        });
      }
    },

This looks like the following:

enter image description here

Thanks for any help, documentation is ridiculously long and I can't find the exact answer

Upvotes: 0

Views: 586

Answers (1)

0x4e
0x4e

Reputation: 106

You can extend the JavaScript Error class.

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",
          },
        });
      }
    },

Upvotes: 2

Related Questions