Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export let NO_ERROR_CODE = "NO_ERROR_CODE";
|
||||
@@ -0,0 +1,64 @@
|
||||
import { LogMessageType } from "@dndbeyond/character-rules-engine/es/logger/constants";
|
||||
|
||||
import { ErrorClientConfig, ErrorCustomTags } from "./typings";
|
||||
|
||||
// Historical note: This logging util used to be more fully featured,
|
||||
// when we integrated with Sentry.io. Now it just logs to the
|
||||
// console if debug is enabled.
|
||||
|
||||
let clientConfig: ErrorClientConfig | null = null;
|
||||
|
||||
/**
|
||||
* Logs an exception when debug is enabled in the client config
|
||||
* @param error The error object
|
||||
* @param contextData Any context data related to the exception
|
||||
* @param customTags
|
||||
*/
|
||||
export function dispatchException(
|
||||
error: Error,
|
||||
contextData: Record<string, any> | null = null,
|
||||
customTags: ErrorCustomTags | null = null
|
||||
): void {
|
||||
if (clientConfig?.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("EXCEPTION", error, contextData, customTags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message when debug is enabled in the client config
|
||||
* @param message The message to send
|
||||
* @param contextData Any context data related to the message
|
||||
* @param customTags
|
||||
* @param severity
|
||||
*/
|
||||
export function dispatchError(
|
||||
message: string,
|
||||
contextData: Record<string, any> | null,
|
||||
customTags: ErrorCustomTags | null,
|
||||
severity: LogMessageType
|
||||
): void {
|
||||
if (clientConfig?.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(severity, message, contextData, customTags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes client error config
|
||||
* @param config config object
|
||||
*/
|
||||
export function initReporting(config: ErrorClientConfig): void {
|
||||
clientConfig = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports a React error to logger
|
||||
* @param error The error to report
|
||||
* @param componentInfo Information about the component in which the error occurred
|
||||
*/
|
||||
export function reportReactError(error: Error, componentInfo: any): void {
|
||||
dispatchException(error, {
|
||||
componentInfo,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user