Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 24c4647

Browse files
committed
feat: catch errors at the end of all observable pipes
1 parent 99f3f79 commit 24c4647

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/extension.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Observable, Observer } from 'rxjs'
2+
import { catchError, of } from 'rxjs'
23
import type { ExtensionContext, OutputChannel } from 'vscode'
34
import { window } from 'vscode'
45
import { registerCommands$ } from './commands'
@@ -39,7 +40,20 @@ export async function activate({
3940
}
4041

4142
const disposables = observables
42-
.map(observable$ => observable$.subscribe(observer))
43+
.map(observable$ =>
44+
observable$
45+
.pipe(
46+
catchError((err: unknown, caught$) => {
47+
return of({
48+
kind: 'UnexpectedError',
49+
message: `Unexpected error: ${JSON.stringify(
50+
err,
51+
)} (caught: ${JSON.stringify(caught$)})`,
52+
} as const)
53+
}),
54+
)
55+
.subscribe(observer),
56+
)
4357
.map(toDisposable)
4458

4559
subscriptions.push(...disposables)

0 commit comments

Comments
 (0)