Skip to content

Commit bd5fe27

Browse files
committed
Add default UNKNOWN event type
1 parent cda1cbd commit bd5fe27

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/boilingdata/boilingdata.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface IBDCallbacks {
1717
onLambdaEvent?: (data: unknown) => void;
1818
onSocketOpen?: () => void;
1919
onSocketClose?: () => void;
20+
unknown?: (data: unknown) => void;
2021
}
2122

2223
export type BDAWSRegion =
@@ -98,6 +99,7 @@ enum ECallbackNames {
9899
INFO = "onInfo",
99100
LAMBDA_EVENT = "onLambdaEvent",
100101
QUERY_FINISHED = "onQueryFinished",
102+
UNKNOWN = "unknown",
101103
}
102104

103105
const createLogger = (props: any): Console => {
@@ -117,7 +119,7 @@ const createLogger = (props: any): Console => {
117119

118120
function mapEventToCallbackName(event: IEvent): ECallbackNames {
119121
const entry = Object.entries(ECallbackNames).find(([key, _value]) => key === event.eventType);
120-
if (!entry) throw new Error(`Mapping event type "${JSON.stringify(event)}" to callback name failed!`);
122+
if (!entry) return ECallbackNames.UNKNOWN; // throw new Error(`Mapping event type "${JSON.stringify(event)}" to callback name failed!`);
121123
return entry[1];
122124
}
123125

0 commit comments

Comments
 (0)