Skip to content

Commit

Permalink
feat(shared): throw error code in production
Browse files Browse the repository at this point in the history
  • Loading branch information
emkis committed Mar 18, 2023
1 parent 732ef79 commit 5304cd8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
9 changes: 6 additions & 3 deletions src/shared/configuration/configuration-errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { EventTrackerError } from '@/shared/error'

export function throwNoConfigurationProvided() {
throw new EventTrackerError(
`You've called configure function without a configuration object.`
)
const message =
process.env.NODE_ENV === 'production'
? '1'
: `You've called configure function without a configuration object.`

throw new EventTrackerError(message)
}
35 changes: 18 additions & 17 deletions src/shared/data-layer/data-layer-error.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { EventTrackerError } from '@/shared/error'

export function throwIsServer() {
throw new EventTrackerError(
'Triggering events is not possible on server-side.' +
'\n\n' +
'Make sure to only trigger events after your app is running on the client-side.'
)
const message =
process.env.NODE_ENV === 'production'
? '1'
: 'Triggering events is not possible on server-side. Make sure to only trigger events after your app is running on the client-side.'

throw new EventTrackerError(message)
}

export function throwIsNotDefined() {
throw new EventTrackerError(
'The targetProperty is not defined.' +
'\n\n' +
`Make sure you didn't forget to add Google Tag Manager's script in your application.` +
'\n\n' +
`If you did but you don't use the default 'window.dataLayer' array, you can set your custom targetProperty with the configure function.`
)
const message =
process.env.NODE_ENV === 'production'
? '1'
: `The targetProperty is not defined. Make sure you didn't forget to add Google Tag Manager's script in your application. If you did but you don't use the default 'window.dataLayer' array, you can set your custom targetProperty with the configure function.`

throw new EventTrackerError(message)
}

export function throwIsNotArray() {
throw new EventTrackerError(
'The targetProperty is not an array.' +
'\n\n' +
`Either you didn't installed Google Tag Manager correctly or you configured the targetProperty incorrectly.`
)
const message =
process.env.NODE_ENV === 'production'
? '1'
: `The targetProperty is not an array. Either you didn't installed Google Tag Manager correctly or you configured the targetProperty incorrectly.`

throw new EventTrackerError(message)
}

0 comments on commit 5304cd8

Please sign in to comment.