mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-14 10:34:48 +08:00
This is a reland of 4df552c652
Original change's description:
> Updates node_modules and update script
>
> Change-Id: I3fcf49bc416301a030d298cfc48c448bfeba4335
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1878808
> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Change-Id: I97d1442c21420488fadde3f17f67cd4e3b959be6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1880030
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
/* tslint:disable:max-classes-per-file */
|
|
|
|
declare class Error {
|
|
public name: string;
|
|
public message: string;
|
|
public index: number;
|
|
public lineNumber: number;
|
|
public column: number;
|
|
public description: string;
|
|
constructor(message: string);
|
|
}
|
|
|
|
export class ErrorHandler {
|
|
readonly errors: Error[];
|
|
tolerant: boolean;
|
|
|
|
constructor() {
|
|
this.errors = [];
|
|
this.tolerant = false;
|
|
}
|
|
|
|
recordError(error: Error): void {
|
|
this.errors.push(error);
|
|
}
|
|
|
|
tolerate(error): void {
|
|
if (this.tolerant) {
|
|
this.recordError(error);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
constructError(msg: string, column: number): Error {
|
|
let error = new Error(msg);
|
|
try {
|
|
throw error;
|
|
} catch (base) {
|
|
/* istanbul ignore else */
|
|
if (Object.create && Object.defineProperty) {
|
|
error = Object.create(base);
|
|
Object.defineProperty(error, 'column', { value: column });
|
|
}
|
|
}
|
|
/* istanbul ignore next */
|
|
return error;
|
|
}
|
|
|
|
createError(index: number, line: number, col: number, description: string): Error {
|
|
const msg = 'Line ' + line + ': ' + description;
|
|
const error = this.constructError(msg, col);
|
|
error.index = index;
|
|
error.lineNumber = line;
|
|
error.description = description;
|
|
return error;
|
|
}
|
|
|
|
throwError(index: number, line: number, col: number, description: string): never {
|
|
throw this.createError(index, line, col, description);
|
|
}
|
|
|
|
tolerateError(index: number, line: number, col: number, description: string) {
|
|
const error = this.createError(index, line, col, description);
|
|
if (this.tolerant) {
|
|
this.recordError(error);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
}
|