Skip to content

Commit 6909b42

Browse files
committed
Fix error during HAR error error logging
Some errors here seemingly don't have this 'errors' property (presumably they have some other cause) and so this throws a different error instead. We now check that more cautiously, and throw the original real error instead.
1 parent 0ae0b66 commit 6909b42

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

custom-typings/har-validator.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare module 'har-validator' {
22
import * as HarFormat from 'har-format';
33
import * as Ajv from 'ajv';
44

5-
export type HarParseError = Ajv.ValidationError;
5+
export type HarParseError = Partial<Ajv.ValidationError>;
66

77
export function har(data: unknown): Promise<HarFormat.Har>;
88
}

src/model/events/events-store.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,13 @@ export class EventsStore {
623623
// Log all suberrors, for easier reporting & debugging.
624624
// This does not include HAR data - only schema errors like
625625
// 'bodySize is missing' at 'entries[1].request'
626-
harParseError.errors.forEach((error) => {
627-
console.log(error);
628-
});
626+
if (harParseError.errors) {
627+
harParseError.errors.forEach((error) => {
628+
console.log(error);
629+
});
630+
} else {
631+
console.log(harParseError);
632+
}
629633
throw harParseError;
630634
});
631635

0 commit comments

Comments
 (0)