File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -65,3 +65,7 @@ export function setUser(uid: string, name: string): void {
6565export function clearUser ( ) : void {
6666 Sentry . setUser ( null ) ;
6767}
68+
69+ export function captureException ( error : Error ) : void {
70+ Sentry . captureException ( error ) ;
71+ }
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ import * as CompositionState from "../states/composition";
7575import { SnapshotResult } from "../constants/default-snapshot" ;
7676import { WordGenError } from "../utils/word-gen-error" ;
7777import { tryCatch } from "@monkeytype/util/trycatch" ;
78+ import { captureException } from "../sentry" ;
7879
7980let failReason = "" ;
8081const koInputVisual = document . getElementById ( "koInputVisual" ) as HTMLElement ;
@@ -382,12 +383,16 @@ export function restart(options = {} as RestartOptions): void {
382383 ResultWordHighlight . destroy ( ) ;
383384}
384385
386+ let lastInitError : Error | null = null ;
385387let rememberLazyMode : boolean ;
386388let testReinitCount = 0 ;
387389export async function init ( ) : Promise < void > {
388390 console . debug ( "Initializing test" ) ;
389391 testReinitCount ++ ;
390392 if ( testReinitCount >= 4 ) {
393+ if ( lastInitError ) {
394+ captureException ( lastInitError ) ;
395+ }
391396 TestUI . setTestRestarting ( false ) ;
392397 Notifications . add (
393398 "Too many test reinitialization attempts. Something is going very wrong. Please contact support." ,
@@ -470,6 +475,9 @@ export async function init(): Promise<void> {
470475 wordsHaveTab = gen . hasTab ;
471476 wordsHaveNewline = gen . hasNewline ;
472477 } catch ( e ) {
478+ if ( e instanceof WordGenError || e instanceof Error ) {
479+ lastInitError = e ;
480+ }
473481 console . error ( e ) ;
474482 if ( e instanceof WordGenError ) {
475483 if ( e . message . length > 0 ) {
You can’t perform that action at this time.
0 commit comments