Files
react-native-devtools-frontend/node_modules/esprima/src/error-handler.ts
T
Paul Lewis 75090cfd93 Reland "Updates node_modules and update script"
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>
2019-10-25 13:19:06 +00:00

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;
}
}
}