UNPKG

1.99 kBTypeScriptView Raw
1/// <reference types="node" />
2import { BrsType, ValueKind } from "./brsTypes";
3import { Location } from "./lexer";
4export declare class BrsError extends Error {
5 readonly location: Location;
6 constructor(message: string, location: Location);
7 /**
8 * Formats the error into a human-readable string including filename, starting and ending line
9 * and column, and the message associated with the error, e.g.:
10 *
11 * `lorem.brs(1,1-3): Expected '(' after sub name`
12 * ```
13 */
14 format(): string;
15}
16/** Wraps up the metadata associated with a type mismatch error. */
17export interface TypeMismatchMetadata {
18 /**
19 * The base message to use for this error. Should be as helpful as possible, e.g.
20 * "Attempting to subtract non-numeric values".
21 */
22 message: string;
23 /** The value on the left-hand side of a binary operator, or the *only* value for a unary operator. */
24 left: TypeAndLocation;
25 /** The value on the right-hand side of a binary operator. */
26 right?: TypeAndLocation;
27}
28export declare type TypeAndLocation = {
29 /** The type of a value involved in a type mismatch. */
30 type: BrsType | ValueKind;
31 /** The location at which the offending value was resolved. */
32 location: Location;
33};
34/**
35 * Creates a "type mismatch"-like error message, but with the appropriate types specified.
36 * @return a type mismatch error that will be tracked by this module.
37 */
38export declare class TypeMismatch extends BrsError {
39 constructor(mismatchMetadata: TypeMismatchMetadata);
40}
41/**
42 * Logs a detected BRS error to console.
43 * @param err the error to log to console
44 */
45export declare function logConsoleError(err: BrsError): void;
46/**
47 * Produces a function that writes errors to the given error stream.
48 * @param errorStream write stream to write errors to.
49 * @returns function that writes to given write stream.
50 */
51export declare function getLoggerUsing(errorStream: NodeJS.WriteStream): (err: BrsError) => boolean;
52
\No newline at end of file