@@ -21,7 +21,6 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
2121import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle' ;
2222import { IStorageService , StorageScope } from 'vs/platform/storage/common/storage' ;
2323import Event , { Emitter } from 'vs/base/common/event' ;
24-
2524import { shell } from 'electron' ;
2625import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration' ;
2726import { isMacintosh } from 'vs/base/common/platform' ;
@@ -36,6 +35,9 @@ export class FileService implements IFileService {
3635 private static readonly NET_VERSION_ERROR = 'System.MissingMethodException' ;
3736 private static readonly NET_VERSION_ERROR_IGNORE_KEY = 'ignoreNetVersionError' ;
3837
38+ private static readonly ENOSPC_ERROR = 'ENOSPC' ;
39+ private static readonly ENOSPC_ERROR_IGNORE_KEY = 'ignoreEnospcError' ;
40+
3941 private raw : NodeFileService ;
4042
4143 private toUnbind : IDisposable [ ] ;
@@ -96,13 +98,17 @@ export class FileService implements IFileService {
9698 return this . _onAfterOperation . event ;
9799 }
98100
99- private onFileServiceError ( msg : string ) : void {
101+ private onFileServiceError ( error : string | Error ) : void {
102+ const msg = error ? error . toString ( ) : void 0 ;
103+ if ( ! msg ) {
104+ return ;
105+ }
100106
101107 // Forward to unexpected error handler
102108 errors . onUnexpectedError ( msg ) ;
103109
104110 // Detect if we run < .NET Framework 4.5 (TODO@ben remove with new watcher impl)
105- if ( typeof msg === 'string' && msg . indexOf ( FileService . NET_VERSION_ERROR ) >= 0 && ! this . storageService . getBoolean ( FileService . NET_VERSION_ERROR_IGNORE_KEY , StorageScope . WORKSPACE ) ) {
111+ if ( msg . indexOf ( FileService . NET_VERSION_ERROR ) >= 0 && ! this . storageService . getBoolean ( FileService . NET_VERSION_ERROR_IGNORE_KEY , StorageScope . WORKSPACE ) ) {
106112 this . messageService . show ( Severity . Warning , < IMessageWithAction > {
107113 message : nls . localize ( 'netVersionError' , "The Microsoft .NET Framework 4.5 is required. Please follow the link to install it." ) ,
108114 actions : [
@@ -120,6 +126,26 @@ export class FileService implements IFileService {
120126 ]
121127 } ) ;
122128 }
129+
130+ // Detect if we run into ENOSPC issues (TODO@ben remove with new watcher impl)
131+ if ( msg . indexOf ( FileService . ENOSPC_ERROR ) >= 0 && ! this . storageService . getBoolean ( FileService . ENOSPC_ERROR_IGNORE_KEY , StorageScope . WORKSPACE ) ) {
132+ this . messageService . show ( Severity . Warning , < IMessageWithAction > {
133+ message : nls . localize ( 'enospcError' , "{0} is running out of file handles. Please follow the instructions link to resolve this issue." , product . nameLong ) ,
134+ actions : [
135+ new Action ( 'learnMore' , nls . localize ( 'learnMore' , "Instructions" ) , null , true , ( ) => {
136+ window . open ( 'https://go.microsoft.com/fwlink/?linkid=867693' ) ;
137+
138+ return TPromise . as ( true ) ;
139+ } ) ,
140+ new Action ( 'enospc.error.ignore' , nls . localize ( 'neverShowAgain' , "Don't Show Again" ) , '' , true , ( ) => {
141+ this . storageService . store ( FileService . ENOSPC_ERROR_IGNORE_KEY , true , StorageScope . WORKSPACE ) ;
142+
143+ return TPromise . as ( null ) ;
144+ } ) ,
145+ CloseAction
146+ ]
147+ } ) ;
148+ }
123149 }
124150
125151 private registerListeners ( ) : void {
0 commit comments