File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1+ import { isApiError , isApiErrorResponse } from "coder/site/src/api/errors"
12import { Workspace , WorkspaceAgent } from "coder/site/src/api/typesGenerated"
23import { z } from "zod"
34
45export function errToStr ( error : unknown , def : string ) {
56 if ( error instanceof Error && error . message ) {
67 return error . message
7- }
8- if ( typeof error === "string" && error . trim ( ) . length > 0 ) {
8+ } else if ( isApiError ( error ) ) {
9+ return error . response . data . message
10+ } else if ( isApiErrorResponse ( error ) ) {
11+ return error . message
12+ } else if ( typeof error === "string" && error . trim ( ) . length > 0 ) {
913 return error
1014 }
1115 return def
Original file line number Diff line number Diff line change @@ -63,8 +63,8 @@ export class WorkspaceMonitor implements vscode.Disposable {
6363 }
6464 } )
6565
66- eventSource . addEventListener ( "error" , ( error ) => {
67- this . notifyError ( error )
66+ eventSource . addEventListener ( "error" , ( event ) => {
67+ this . notifyError ( event . data )
6868 } )
6969
7070 // Store so we can close in dispose().
@@ -182,9 +182,9 @@ export class WorkspaceMonitor implements vscode.Disposable {
182182 }
183183
184184 private notifyError ( error : unknown ) {
185- const message = errToStr ( error , "No error message was provided" )
185+ // For now, we are not bothering the user about this.
186+ const message = errToStr ( error , "Got empty error" )
186187 this . storage . writeToCoderOutputChannel ( message )
187- vscode . window . showErrorMessage ( `Failed to monitor workspace: ${ message } ` )
188188 }
189189
190190 private updateContext ( workspace : Workspace ) {
You can’t perform that action at this time.
0 commit comments