• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / brs / #310

01 Dec 2023 08:37PM UTC coverage: 91.498% (+1.0%) from 90.458%
#310

push

TwitchBronBron
0.45.3

1784 of 2079 branches covered (85.81%)

Branch coverage included in aggregate %.

5265 of 5625 relevant lines covered (93.6%)

8959.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/Error.ts
1
import type { Location } from "./lexer";
2

3
export class BrsError extends Error {
140✔
4
    constructor(message: string, readonly location: Location) {
290✔
5
        super(message);
290✔
6
    }
7

8
    /**
9
     * Formats the error into a human-readable string including filename, starting and ending line
10
     * and column, and the message associated with the error, e.g.:
11
     *
12
     * `lorem.brs(1,1-3): Expected '(' after sub name`
13
     * @see BrsError#format
14
     */
15
    format() {
16
        return BrsError.format(this.message, this.location);
17✔
17
    }
18

19
    /**
20
     * Formats a location and message into a human-readable string including filename, starting
21
     * and ending line and column, and the message associated with the error, e.g.:
22
     *
23
     * `lorem.brs(1,1-3): Expected '(' after sub name`
24
     *
25
     * @param message a string describing the error
26
     * @param location where the error occurred
27
     */
28
    static format(message: string, location: Location): string {
29
        let formattedLocation: string;
30

31
        if (location.start.line === location.end.line) {
17!
32
            let columns = `${location.start.column}`;
17✔
33
            if (location.start.column !== location.end.column) {
17✔
34
                columns += `-${location.end.column}`;
17✔
35
            }
36
            formattedLocation = `${location.file}(${location.start.line},${columns})`;
17✔
37
        } else {
38
            formattedLocation = `${location.file}(${location.start.line},${location.start.column},${location.end.line},${location.end.line})`;
×
39
        }
40

41
        return `${formattedLocation}: ${message}\n`;
17✔
42
    }
43
}
44

45
/**
46
 * Logs a detected BRS error to console.
47
 * @param err the error to log to console
48
 */
49
export function logConsoleError(err: BrsError) {
140✔
50
    console.error(err.format());
×
51
}
52

53
/**
54
 * Produces a function that writes errors to the given error stream.
55
 * @param errorStream write stream to write errors to.
56
 * @returns function that writes to given write stream.
57
 */
58
export function getLoggerUsing(errorStream: NodeJS.WriteStream): (err: BrsError) => boolean {
140✔
59
    return (err) => errorStream.write(err.format());
4,488✔
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc