Skip to content

Commit

Permalink
replace assertNever
Browse files Browse the repository at this point in the history
  • Loading branch information
tdraier committed Nov 21, 2024
1 parent 27fa953 commit 05a9501
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions extension/app/src/components/conversation/AgentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
} from "@extension/components/markdown/MentionBlock";
import { useSubmitFunction } from "@extension/components/utils/useSubmitFunction";
import { useEventSource } from "@extension/hooks/useEventSource";
import { assertNeverAndIgnore } from "@extension/lib/asserNever";
import { retryMessage } from "@extension/lib/conversation";
import {
useCallback,
Expand Down Expand Up @@ -271,13 +272,17 @@ export function AgentMessage({
});
break;
default:
assertNever(event.classification);
// Log message and do nothing. Don't crash if a new token classification is not handled here.
assertNeverAndIgnore(event.classification);
break;
}
break;
}

default:
assertNever(event);
// Log message and do nothing. Don't crash if a new event type is not handled here.
assertNeverAndIgnore(event);
break;
}
}, []);

Expand Down
5 changes: 5 additions & 0 deletions extension/app/src/lib/asserNever.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function assertNeverAndIgnore(x: never): void {
console.log(
`${typeof x === "object" ? JSON.stringify(x) : x} is not handled.`
);
}

0 comments on commit 05a9501

Please sign in to comment.