@@ -243,7 +243,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
243
243
if ( ! api . active ) throw vscode . FileSystemError . Unavailable ( "Server connection is inactive" ) ;
244
244
let entryPromise : Promise < Entry > ;
245
245
let result : Entry ;
246
- const redirectedUri = redirectDotvscodeRoot ( uri ) ;
246
+ const redirectedUri = redirectDotvscodeRoot ( uri , vscode . FileSystemError . FileNotFound ( uri ) ) ;
247
247
if ( redirectedUri . path !== uri . path ) {
248
248
// When redirecting the /.vscode subtree we must fill in as-yet-unvisited folders to fix https://github.com/intersystems-community/vscode-objectscript/issues/1143
249
249
entryPromise = this . _lookup ( redirectedUri , true ) ;
@@ -290,8 +290,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
290
290
}
291
291
292
292
public async readDirectory ( uri : vscode . Uri ) : Promise < [ string , vscode . FileType ] [ ] > {
293
- if ( uri . path . includes ( ".vscode/" ) ) {
294
- throw vscode . FileSystemError . NoPermissions ( "Cannot read the /.vscode directory" ) ;
293
+ if ( uri . path . includes ( ".vscode/" ) || uri . path . endsWith ( ".vscode" ) ) {
294
+ throw new vscode . FileSystemError ( "Cannot read the /.vscode directory" ) ;
295
295
}
296
296
const parent = await this . _lookupAsDirectory ( uri ) ;
297
297
const api = new AtelierAPI ( uri ) ;
@@ -406,7 +406,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
406
406
}
407
407
408
408
public createDirectory ( uri : vscode . Uri ) : void | Thenable < void > {
409
- uri = redirectDotvscodeRoot ( uri ) ;
409
+ uri = redirectDotvscodeRoot ( uri , new vscode . FileSystemError ( "Server does not have a /_vscode web application" ) ) ;
410
410
const basename = path . posix . basename ( uri . path ) ;
411
411
const dirname = uri . with ( { path : path . posix . dirname ( uri . path ) } ) ;
412
412
return this . _lookupAsDirectory ( dirname ) . then ( ( parent ) => {
@@ -435,9 +435,9 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
435
435
overwrite : boolean ;
436
436
}
437
437
) : void | Thenable < void > {
438
- uri = redirectDotvscodeRoot ( uri ) ;
438
+ uri = redirectDotvscodeRoot ( uri , new vscode . FileSystemError ( "Server does not have a /_vscode web application" ) ) ;
439
439
if ( uri . path . startsWith ( "/." ) ) {
440
- throw vscode . FileSystemError . NoPermissions ( "dot-folders not supported by server" ) ;
440
+ throw new vscode . FileSystemError ( "dot-folders are not supported by server" ) ;
441
441
}
442
442
const csp = isCSP ( uri ) ;
443
443
const fileName = isfsDocumentName ( uri , csp ) ;
@@ -462,10 +462,12 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
462
462
[ , clsname ] = match ;
463
463
}
464
464
if ( clsname == "" ) {
465
- throw new Error ( "Cannot save a malformed class" ) ;
465
+ throw new vscode . FileSystemError ( "Cannot save a malformed class" ) ;
466
466
}
467
467
if ( fileName . slice ( 0 , - 4 ) != clsname ) {
468
- throw new Error ( "Cannot save an isfs class where the class name and file name do not match" ) ;
468
+ throw new vscode . FileSystemError (
469
+ "Cannot save an isfs class where the class name and file name do not match"
470
+ ) ;
469
471
}
470
472
if ( openLowCodeEditors . has ( uri . toString ( ) ) ) {
471
473
// This class is open in a low-code editor, so any
@@ -474,7 +476,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
474
476
}
475
477
// Check if the class is deployed
476
478
if ( await isClassDeployed ( fileName , api ) ) {
477
- throw new Error ( "Cannot overwrite a deployed class" ) ;
479
+ throw new vscode . FileSystemError ( "Cannot overwrite a deployed class" ) ;
478
480
}
479
481
}
480
482
const contentBuffer = Buffer . from ( content ) ;
@@ -505,7 +507,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
505
507
. catch ( ( error ) => {
506
508
// Throw all failures
507
509
const errorStr = stringifyError ( error ) ;
508
- throw errorStr ? errorStr : vscode . FileSystemError . Unavailable ( uri ) ;
510
+ throw errorStr ? new vscode . FileSystemError ( errorStr ) : vscode . FileSystemError . Unavailable ( uri ) ;
509
511
} ) ;
510
512
} ,
511
513
( error ) => {
@@ -529,7 +531,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
529
531
. catch ( ( error ) => {
530
532
// Throw all failures
531
533
const errorStr = stringifyError ( error ) ;
532
- throw errorStr ? errorStr : vscode . FileSystemError . Unavailable ( uri ) ;
534
+ throw errorStr ? new vscode . FileSystemError ( errorStr ) : vscode . FileSystemError . Unavailable ( uri ) ;
533
535
} )
534
536
. then ( ( data ) => {
535
537
// New file has been written
@@ -639,7 +641,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
639
641
}
640
642
641
643
public async delete ( uri : vscode . Uri , options : { recursive : boolean } ) : Promise < void > {
642
- uri = redirectDotvscodeRoot ( uri ) ;
644
+ uri = redirectDotvscodeRoot ( uri , vscode . FileSystemError . FileNotFound ( uri ) ) ;
643
645
const { project } = isfsConfig ( uri ) ;
644
646
const csp = isCSP ( uri ) ;
645
647
const api = new AtelierAPI ( uri ) ;
@@ -724,13 +726,13 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
724
726
725
727
public async rename ( oldUri : vscode . Uri , newUri : vscode . Uri , options : { overwrite : boolean } ) : Promise < void > {
726
728
if ( ! oldUri . path . split ( "/" ) . pop ( ) . includes ( "." ) ) {
727
- throw vscode . FileSystemError . NoPermissions ( "Cannot rename a package/folder" ) ;
729
+ throw new vscode . FileSystemError ( "Cannot rename a package/folder" ) ;
728
730
}
729
731
if ( oldUri . path . split ( "." ) . pop ( ) . toLowerCase ( ) != newUri . path . split ( "." ) . pop ( ) . toLowerCase ( ) ) {
730
- throw vscode . FileSystemError . NoPermissions ( "Cannot change a file's extension during rename" ) ;
732
+ throw new vscode . FileSystemError ( "Cannot change a file's extension during rename" ) ;
731
733
}
732
734
if ( vscode . workspace . getWorkspaceFolder ( oldUri ) != vscode . workspace . getWorkspaceFolder ( newUri ) ) {
733
- throw vscode . FileSystemError . NoPermissions ( "Cannot rename a file across workspace folders" ) ;
735
+ throw new vscode . FileSystemError ( "Cannot rename a file across workspace folders" ) ;
734
736
}
735
737
// Check if the destination exists
736
738
let newFileStat : vscode . FileStat ;
@@ -774,7 +776,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
774
776
. catch ( ( error ) => {
775
777
// Throw all failures
776
778
const errorStr = stringifyError ( error ) ;
777
- throw errorStr ? errorStr : vscode . FileSystemError . Unavailable ( newUri ) ;
779
+ throw errorStr ? new vscode . FileSystemError ( errorStr ) : vscode . FileSystemError . Unavailable ( newUri ) ;
778
780
} )
779
781
. then ( async ( response ) => {
780
782
// New file has been written
@@ -807,7 +809,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
807
809
*/
808
810
public async compile ( uri : vscode . Uri , file ?: File , update ?: boolean ) : Promise < void > {
809
811
if ( ! uri || uri . scheme != FILESYSTEM_SCHEMA ) return ;
810
- uri = redirectDotvscodeRoot ( uri ) ;
812
+ uri = redirectDotvscodeRoot ( uri , new vscode . FileSystemError ( "Server does not have a /_vscode web application" ) ) ;
811
813
const compileList : string [ ] = [ ] ;
812
814
try {
813
815
const entry = file || ( await this . _lookup ( uri , true ) ) ;
@@ -958,9 +960,9 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
958
960
959
961
// Fetch from server and cache it, optionally the passed cached copy if unchanged on server
960
962
private async _lookupAsFile ( uri : vscode . Uri , cachedFile ?: File ) : Promise < File > {
961
- uri = redirectDotvscodeRoot ( uri ) ;
963
+ uri = redirectDotvscodeRoot ( uri , vscode . FileSystemError . FileNotFound ( uri ) ) ;
962
964
if ( uri . path . startsWith ( "/." ) ) {
963
- throw vscode . FileSystemError . NoPermissions ( "dot-folders not supported by server" ) ;
965
+ throw new vscode . FileSystemError ( "dot-folders are not supported by server" ) ;
964
966
}
965
967
const csp = isCSP ( uri ) ;
966
968
const name = path . basename ( uri . path ) ;
@@ -992,13 +994,13 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
992
994
throw error ?. statusCode == 404
993
995
? vscode . FileSystemError . FileNotFound ( uri )
994
996
: errorStr
995
- ? errorStr
997
+ ? new vscode . FileSystemError ( errorStr )
996
998
: vscode . FileSystemError . Unavailable ( uri ) ;
997
999
} ) ;
998
1000
}
999
1001
1000
1002
private async _lookupParentDirectory ( uri : vscode . Uri ) : Promise < Directory > {
1001
- uri = redirectDotvscodeRoot ( uri ) ;
1003
+ uri = redirectDotvscodeRoot ( uri , new vscode . FileSystemError ( "Server does not have a /_vscode web application" ) ) ;
1002
1004
return this . _lookupAsDirectory ( uri . with ( { path : path . posix . dirname ( uri . path ) } ) ) ;
1003
1005
}
1004
1006
0 commit comments