mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-02 06:23:53 +03:00
b82de74592
* Use rollup for d3tooltip * Use rollup for map2tree * Set moduleResolution * Use rollup for d3-state-visualizer * Use rollup for react-base16-styling * Use rollup for react-dock * Use rollup for react-json-tree * Use rollup for redux-devtools * Use rollup for redux-devtools-intrument * Use rollup for redux-devtools-chart-monitor * Update export * Use rollup for redux-devtools-dock-monitor * Use rollup for redux-devtools-inspector-monitor * Fix inspector demo * Fix invalid eslint config * Use rollup for inspector-monitor-test-tab * Use rollup for inspector-monitor-trace-tab * Use rollup for redux-devtools-log-monitor * Use rollup for redux-devtools-remote * Use rollup in redux-devtools-rtk-query-monitor * Use rollup for redux-devtools-serialize * Fix redux-devtools examples * Use rollup for redux-devtools-slider-monitor * Fix slider examples * Use rollup for redux-devtools-ui * Use rollup for redux-devtools-utils * Use rollup for redux-devtools-extension * Use rollup for redux-devtools-app * Fix Webpack app build * Fix extension build * Turn on minimization * Update CLI
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
const ERROR = '@@redux-devtools/ERROR';
|
|
|
|
export interface ErrorAction {
|
|
type: typeof ERROR;
|
|
message?: Event | string;
|
|
url?: string | undefined;
|
|
lineNo?: number | undefined;
|
|
columnNo?: number | undefined;
|
|
stack?: string;
|
|
error?: Error;
|
|
isFatal?: boolean;
|
|
sourceURL?: string;
|
|
line?: number;
|
|
column?: number;
|
|
}
|
|
|
|
export function catchErrors(sendError: (errorAction: ErrorAction) => void) {
|
|
if (typeof window === 'object' && typeof window.onerror === 'object') {
|
|
window.onerror = function (message, url, lineNo, columnNo, error) {
|
|
const errorAction: ErrorAction = {
|
|
type: ERROR,
|
|
message,
|
|
url,
|
|
lineNo,
|
|
columnNo,
|
|
};
|
|
if (error && error.stack) errorAction.stack = error.stack;
|
|
sendError(errorAction);
|
|
return false;
|
|
};
|
|
} else if (typeof global !== 'undefined' && (global as any).ErrorUtils) {
|
|
(global as any).ErrorUtils.setGlobalHandler(
|
|
(error: Error, isFatal: boolean) => {
|
|
sendError({ type: ERROR, error, isFatal });
|
|
}
|
|
);
|
|
}
|
|
|
|
/* eslint-disable no-console */
|
|
if (
|
|
typeof console === 'object' &&
|
|
typeof console.error === 'function' &&
|
|
!(console as any).beforeRemotedev
|
|
) {
|
|
(console as any).beforeRemotedev = console.error.bind(console);
|
|
console.error = function () {
|
|
let errorAction: ErrorAction = { type: ERROR };
|
|
// eslint-disable-next-line prefer-rest-params
|
|
const error = arguments[0];
|
|
errorAction.message = error.message ? error.message : error;
|
|
if (error.sourceURL) {
|
|
errorAction = {
|
|
...errorAction,
|
|
sourceURL: error.sourceURL,
|
|
line: error.line,
|
|
column: error.column,
|
|
};
|
|
}
|
|
if (error.stack) errorAction.stack = error.stack;
|
|
sendError(errorAction);
|
|
// eslint-disable-next-line prefer-rest-params
|
|
(console as any).beforeRemotedev.apply(null, arguments);
|
|
};
|
|
}
|
|
/* eslint-enable no-console */
|
|
}
|