Skip to content

Commit

Permalink
feat(error): throw minified error message
Browse files Browse the repository at this point in the history
  • Loading branch information
emkis committed Mar 19, 2023
1 parent 86b0702 commit 13611dc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/shared/error/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
function createErrorMessage(message: string) {
if (process.env.NODE_ENV === 'production') {
const errorCode = message
return `Minified EventTrackerError error #${errorCode}. Visit https://github.com/emkis/gtm-event-tracker#error-codes for the full message.`
}

return message
}

export class EventTrackerError extends Error {
constructor(message: string) {
super(message)
const parsedMessage = createErrorMessage(message)
super(parsedMessage)
this.name = 'EventTrackerError'
}
}

0 comments on commit 13611dc

Please sign in to comment.