Reputation: 57
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:
Thanks for any help, documentation is ridiculously long and I can't find the exact answer
Upvotes: 0
Views: 586
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