Skip to content

Commit c653901

Browse files
committed
fix(lighthouse): update Lighthouse error handling to use State enum
1 parent 1ee8ba5 commit c653901

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/runtime/classes/lighthouse/Stats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum State {
1+
export enum State {
22
READY,
33
FAIL,
44
PENDING

src/runtime/utils/lighthouse.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
LighthouseStats,
3-
READY,
4-
FAIL,
5-
PENDING
6-
} from '../classes/lighthouse/Stats';
1+
import { LighthouseStats, State } from '../classes/lighthouse/Stats';
72
import LighthouseError from '../classes/lighthouse/Error';
83

94
let controller: AbortController | undefined;
@@ -35,7 +30,7 @@ export function getLighthouseMetrics(url: string) {
3530
}
3631

3732
export function getPendingStats() {
38-
return new LighthouseError(PENDING);
33+
return new LighthouseError(State.PENDING);
3934
}
4035

4136
function getAbortSignal() {
@@ -48,7 +43,7 @@ function getAbortSignal() {
4843

4944
async function handleResponse(response: Response) {
5045
if (!response.ok) {
51-
throw new LighthouseError(FAIL);
46+
throw new LighthouseError(State.FAIL);
5247
}
53-
return new LighthouseStats(READY, await response.json());
48+
return new LighthouseStats(State.READY, await response.json());
5449
}

0 commit comments

Comments
 (0)