forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskError.ts
More file actions
48 lines (39 loc) · 1.14 KB
/
TaskError.ts
File metadata and controls
48 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
/**
* Encapsulates information about an error
*/
export class TaskError extends Error {
protected _type: string;
public constructor(type: string, message: string) {
super(message);
this._type = type;
}
public get message(): string {
return `[${this._type}] '${super.message}'`;
}
public toString(): string {
return this.message;
}
}
/**
* TestTaskError extends TaskError
*/
export class BuildTaskError extends TaskError {
protected _file: string;
protected _line: number;
protected _offset: number;
public constructor(type: string, message: string, file: string, line: number, offset: number) {
super(type, message);
this._file = file;
this._line = line;
this._offset = offset;
}
public get message(): string {
// Example: "C:\Project\Blah.ts(123,1): [tslint] error no-any: 'any' is not allowed"
return `${this._file}(${this._line},${this._offset}): ${super.message}`;
}
public toString(): string {
return this.message;
}
}