Skip to content

Commit 752e434

Browse files
authored
Shorten server-side error messages (#1587)
1 parent 58146d0 commit 752e434

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
504504
})
505505
.catch((error) => {
506506
// Throw all failures
507-
throw vscode.FileSystemError.Unavailable(stringifyError(error) || uri);
507+
const errorStr = stringifyError(error);
508+
throw errorStr ? errorStr : vscode.FileSystemError.Unavailable(uri);
508509
});
509510
},
510511
(error) => {
@@ -527,7 +528,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
527528
)
528529
.catch((error) => {
529530
// Throw all failures
530-
throw vscode.FileSystemError.Unavailable(stringifyError(error) || uri);
531+
const errorStr = stringifyError(error);
532+
throw errorStr ? errorStr : vscode.FileSystemError.Unavailable(uri);
531533
})
532534
.then((data) => {
533535
// New file has been written
@@ -771,7 +773,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
771773
)
772774
.catch((error) => {
773775
// Throw all failures
774-
throw vscode.FileSystemError.Unavailable(stringifyError(error) || newUri);
776+
const errorStr = stringifyError(error);
777+
throw errorStr ? errorStr : vscode.FileSystemError.Unavailable(newUri);
775778
})
776779
.then(async (response) => {
777780
// New file has been written
@@ -985,9 +988,12 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
985988
)
986989
.catch((error) => {
987990
if (error?.statusCode == 304 && cachedFile) return cachedFile;
988-
const errArg = stringifyError(error) || uri;
989-
if (error?.statusCode == 404) throw vscode.FileSystemError.FileNotFound(errArg);
990-
throw vscode.FileSystemError.Unavailable(errArg);
991+
const errorStr = stringifyError(error);
992+
throw error?.statusCode == 404
993+
? vscode.FileSystemError.FileNotFound(uri)
994+
: errorStr
995+
? errorStr
996+
: vscode.FileSystemError.Unavailable(uri);
991997
});
992998
}
993999

0 commit comments

Comments
 (0)