-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
13 additions
and
9 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
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
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 |
---|---|---|
|
@@ -33,11 +33,16 @@ export function throwUserError(message: string) { | |
* where the user can get support. This should be called for errors that are unexpected and could | ||
* point to issues in the connector, or for errors that are not easy for the user to resolve themselves. | ||
* | ||
* @param message | ||
* @param error Error the error that occurred | ||
* @param callerId | ||
* @throws Error | ||
*/ | ||
export function throwUnexpectedError(message: string) { | ||
export function throwUnexpectedError(error: Error, callerId?: string) { | ||
try { | ||
const { message, stack } = error; | ||
|
||
log(`Unexpected error${callerId ? ` in ${callerId}` : ''}: ${stack}`); | ||
|
||
const time = (new Date()).toString(); | ||
const wholeMessage = `An error has occurred - if you need help, please reach out in the Forums here: ${FORUM_URL} or ` | ||
+ `contact us by email at [email protected] (in your message, please use Looker Studio in the subject, and copy paste the error message). ` | ||
|
@@ -77,7 +82,6 @@ export function callWithUserFriendlyErrorHandling<T>(callerId: string, fn: () => | |
throw e; | ||
} | ||
|
||
log(`Unexpected error: ${e.stack || e.message || e}`); | ||
throwUnexpectedError(`${callerId}: ${e.message || e}`); | ||
throwUnexpectedError(e, callerId); | ||
} | ||
} |