Skip to content

Commit 3b34320

Browse files
committed
Fix throwing non-new Errors and literals
1 parent 3a00c29 commit 3b34320

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

packages/compute-baseline/src/browser-compat-data/browser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class Browser {
5858
const curr = this.releases.find((r) => r.data.status === "current");
5959

6060
if (curr === undefined) {
61-
throw Error(`${browser} does not have a "current" release`);
61+
throw new Error(`${browser} does not have a "current" release`);
6262
}
6363

6464
return curr;
@@ -67,7 +67,7 @@ export class Browser {
6767
version(versionString: string): Release {
6868
const result = this.releases.find((r) => r.version === versionString);
6969
if (result === undefined) {
70-
throw Error(`${browser} does not have a '${versionString}' release.`);
70+
throw new Error(`${browser} does not have a '${versionString}' release.`);
7171
}
7272
return result;
7373
}

packages/compute-baseline/src/browser-compat-data/feature.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Feature {
2727

2828
constructor(id: string, featureData: unknown) {
2929
if (!isFeatureData(featureData)) {
30-
throw `${id} is not valid feature`;
30+
throw new Error(`${id} is not valid feature`);
3131
}
3232

3333
this.id = id;
@@ -77,13 +77,13 @@ export class Feature {
7777
): { release: Release; qualifications?: Qualifications }[] {
7878
const support = this.data?.__compat?.support;
7979
if (support === undefined) {
80-
throw Error("This feature contains no __compat object.");
80+
throw new Error("This feature contains no __compat object.");
8181
}
8282

8383
const statementOrStatements = support[browser.id];
8484

8585
if (statementOrStatements === undefined) {
86-
throw Error(`${this} contains no support data for ${browser.name}`);
86+
throw new Error(`${this} contains no support data for ${browser.name}`);
8787
}
8888

8989
const rawStatements = Array.isArray(statementOrStatements)
@@ -95,7 +95,7 @@ export class Feature {
9595
const s = statement(raw, browser, this);
9696

9797
if (!(s instanceof RealSupportStatement)) {
98-
throw Error(
98+
throw new Error(
9999
`${this.id} contains non-real values for ${browser.name}. Cannot expand support.`,
100100
);
101101
}

packages/compute-baseline/src/browser-compat-data/release.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class Release {
3636

3737
compare(otherRelease: Release) {
3838
if (otherRelease.browser !== this.browser) {
39-
throw Error(
39+
throw new Error(
4040
`Cannot compare releases of differing browsers (${this.browser} versus ${otherRelease.browser})`,
4141
);
4242
}

packages/compute-baseline/src/browser-compat-data/supportStatements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class RealSupportStatement extends SupportStatement {
153153
// returning `[this.browser.current()]` at least.
154154
supportedBy(): { release: Release; qualifications?: Qualifications }[] {
155155
if (this.browser === undefined) {
156-
throw Error("This support statement's browser is unknown.");
156+
throw new Error("This support statement's browser is unknown.");
157157
}
158158

159159
if (this.version_added === false) {

packages/compute-baseline/src/browser-compat-data/walk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function* walk(entryPoints: string | string[], data: BCD) {
7373
if (isFeatureData(queryResult)) {
7474
return lowLevelWalk(queryResult, entryPoint);
7575
}
76-
throw Error("Unhandled traverse target");
76+
throw new Error("Unhandled traverse target");
7777
}),
7878
);
7979
}

packages/compute-baseline/src/browser-compat-data/walkUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function descendantKeys(data: unknown, path?: string): string[] {
3838
return Object.keys(data).filter((key) => key !== "__compat");
3939
}
4040

41-
throw Error(
41+
throw new Error(
4242
`Unhandled traverse into descendants of object at ${path ?? "[root]"}`,
4343
);
4444
}

0 commit comments

Comments
 (0)