@lwc/errors
Version:
LWC Error Utilities
45 lines • 1.78 kB
TypeScript
import { DiagnosticLevel } from '../shared/types';
import type { Location } from '../shared/types';
export interface CompilerDiagnosticOrigin {
filename?: string;
location?: Location;
}
export interface CompilerDiagnostic {
message: string;
code: number;
filename?: string;
location?: Location;
level: DiagnosticLevel;
}
export declare class CompilerError extends Error implements CompilerDiagnostic {
code: number;
filename?: string;
location?: Location;
level: DiagnosticLevel;
constructor(code: number, message: string, filename?: string, location?: Location);
static from(diagnostic: CompilerDiagnostic, origin?: CompilerDiagnosticOrigin): CompilerError;
toDiagnostic(): CompilerDiagnostic;
}
/**
* Extracts an error code from the given error.
* @param error The error to check.
* @returns The error code, if found.
*/
export declare function getCodeFromError(error: any): number | undefined;
/**
* Extracts the filename from the provided parameters, preferring to use the compiler diagnostic
* origin, if provided.
* @param origin Compiler diagnositic origin data
* @param obj Any object that might have a filename associated
* @returns The filename, if found.
*/
export declare function getFilename(origin: CompilerDiagnosticOrigin | undefined, obj?: any): string | undefined;
/**
* Extracts the location from the provided parameters, preferring to use the compiler diagnostic
* origin, if provided.
* @param origin Compiler diagnositic origin data
* @param obj Any object that might have a location property
* @returns The location, if found.
*/
export declare function getLocation(origin: CompilerDiagnosticOrigin | undefined, obj?: any): Location | undefined;
//# sourceMappingURL=utils.d.ts.map