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

nightlycommit / twing / 307

02 Jun 2025 09:53AM UTC coverage: 100.0%. Remained the same
307

push

gitlab-ci

Eric MORAND
Replace useless https protocol with http.

2541 of 2541 branches covered (100.0%)

Branch coverage included in aggregate %.

5851 of 5851 relevant lines covered (100.0%)

2499.09 hits per line

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

100.0
/src/main/lib/error/base.ts
1
import type {TwingSource} from "../source";
2

3
export type TwingErrorLocation = {
4
    line: number;
5
    column: number;
6
};
7

8
export interface TwingBaseError<Name extends string> extends Error {
9
    readonly name: Name;
10
    readonly previous: any | undefined;
11
    readonly rootMessage: string;
12
    location: TwingErrorLocation;
13
    source: TwingSource;
14
    
15
    appendMessage(message: string): void;
16
}
17

18
export const createBaseError = <Name extends string>(
1✔
19
    name: Name, message: string, location: TwingErrorLocation, source: TwingSource, previous?: any
20
): TwingBaseError<Name> => {
21
    const baseError = Error(message);
342✔
22

23
    baseError.name = name;
342✔
24

25
    const error = Object.create(baseError, {
342✔
26
        location: {
27
            get: () => location
28
        },
29
        source: {
30
            get: () => source
31
        },
32
        previous: {
33
            value: previous
34
        },
35
        rootMessage: {
36
            value: message
37
        },
38
        appendMessage: {
39
            value: (value: string) => {
40
                message += value;
7✔
41

42
                updateRepresentation();
7✔
43
            }
44
        }
45
    });
46

47
    const updateRepresentation = () => {
342✔
48
        let representation = message;
349✔
49

50
        let dot = false;
349✔
51

52
        if (representation.slice(-1) === '.') {
349✔
53
            representation = representation.slice(0, -1);
328✔
54
            dot = true;
328✔
55
        }
56

57
        let questionMark = false;
349✔
58

59
        if (representation.slice(-1) === '?') {
349✔
60
            representation = representation.slice(0, -1);
9✔
61
            questionMark = true;
9✔
62
        }
63

64
        representation += ` in "${source.name}"`;
349✔
65

66
        const {line, column} = location;
349✔
67

68
        representation += ` at line ${line}, column ${column}`;
349✔
69

70
        if (dot) {
349✔
71
            representation += '.';
328✔
72
        }
73

74
        if (questionMark) {
349✔
75
            representation += '?';
9✔
76
        }
77
        
78
        baseError.message = representation;
349✔
79
    };
80

81
    updateRepresentation();
342✔
82

83
    Error.captureStackTrace(error, createBaseError);
342✔
84

85
    return error;
342✔
86
}
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

© 2025 Coveralls, Inc