mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 19:00:09 -04:00
29 lines
567 B
JavaScript
29 lines
567 B
JavaScript
import PromiseRejectionError from '@/lib/promise-rejection-error';
|
|
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export class ErrorHandler {
|
|
constructor() {
|
|
this.logToConsole = true;
|
|
this.reset();
|
|
}
|
|
|
|
reset() {
|
|
this.error = null;
|
|
}
|
|
|
|
process(error) {
|
|
this.reset();
|
|
if (this.logToConsole) {
|
|
// Log raw error object
|
|
// eslint-disable-next-line no-console
|
|
console.error(error);
|
|
}
|
|
if (
|
|
(error === null) ||
|
|
(error instanceof PromiseRejectionError)
|
|
) {
|
|
this.error = error;
|
|
}
|
|
}
|
|
}
|