-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shared): throw error code in production
- Loading branch information
Showing
2 changed files
with
24 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |