File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/cursorless-engine/src/nodeCommon Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export class TalonSpokenFormsJsonReader implements TalonSpokenForms {
50
50
await readFile ( this . cursorlessTalonStateJsonPath , "utf-8" ) ,
51
51
) ;
52
52
} catch ( err ) {
53
- if ( ( err as any ) ? .code === "ENOENT" ) {
53
+ if ( isErrnoException ( err ) && err . code === "ENOENT" ) {
54
54
throw new NeedsInitialTalonUpdateError (
55
55
`Custom spoken forms file not found at ${ this . cursorlessTalonStateJsonPath } . Using default spoken forms.` ,
56
56
) ;
@@ -73,3 +73,15 @@ export class TalonSpokenFormsJsonReader implements TalonSpokenForms {
73
73
this . disposer . dispose ( ) ;
74
74
}
75
75
}
76
+
77
+ /**
78
+ * A user-defined type guard function that checks if a given error is a
79
+ * `NodeJS.ErrnoException`.
80
+ *
81
+ * @param {any } error - The error to check.
82
+ * @returns {error is NodeJS.ErrnoException } - Returns `true` if the error is a
83
+ * {@link NodeJS.ErrnoException}, otherwise `false`.
84
+ */
85
+ function isErrnoException ( error : any ) : error is NodeJS . ErrnoException {
86
+ return error instanceof Error && "code" in error ;
87
+ }
You can’t perform that action at this time.
0 commit comments