@@ -23,6 +23,15 @@ const loadDeps = () => {
2323 }
2424} ;
2525
26+ const getCheckNotificationDetails = checkDetail =>
27+ ( notification ) => {
28+ const { detail } = notification . getOptions ( ) ;
29+ if ( detail === checkDetail ) {
30+ return true ;
31+ }
32+ return false ;
33+ } ;
34+
2635export default {
2736 activate ( ) {
2837 this . idleCallbacks = new Set ( ) ;
@@ -47,11 +56,15 @@ export default {
4756 'linter-csslint.executablePath' ,
4857 ( value ) => { this . executablePath = value ; } ,
4958 ) ) ;
59+
60+ this . activeNotifications = new Set ( ) ;
5061 } ,
5162
5263 deactivate ( ) {
5364 this . idleCallbacks . forEach ( callbackID => window . cancelIdleCallback ( callbackID ) ) ;
5465 this . idleCallbacks . clear ( ) ;
66+ this . activeNotifications . forEach ( notification => notification . dismiss ( ) ) ;
67+ this . activeNotifications . clear ( ) ;
5568 this . subscriptions . dispose ( ) ;
5669 } ,
5770
@@ -90,7 +103,34 @@ export default {
90103
91104 const execPath = this . determineExecPath ( this . executablePath , projectPath ) ;
92105
93- const output = await helpers . exec ( execPath , parameters , execOptions ) ;
106+ let output ;
107+ try {
108+ output = await helpers . exec ( execPath , parameters , execOptions ) ;
109+ } catch ( e ) {
110+ // eslint-disable-next-line no-console
111+ console . error ( e ) ;
112+
113+ // Check if the notification is currently showing to the user
114+ const checkNotificationDetails = getCheckNotificationDetails ( e . message ) ;
115+ if ( Array . from ( this . activeNotifications ) . some ( checkNotificationDetails ) ) {
116+ // This message is still showing to the user!
117+ return null ;
118+ }
119+
120+ // Notify the user
121+ const message = 'linter-csslint:: Error while running CSSLint!' ;
122+ const options = {
123+ detail : e . message ,
124+ dismissable : true ,
125+ } ;
126+ const notification = atom . notifications . addError ( message , options ) ;
127+ this . activeNotifications . add ( notification ) ;
128+ // Remove it when the user closes the notification
129+ notification . onDidDismiss ( ( ) => this . activeNotifications . delete ( notification ) ) ;
130+
131+ // Don't update any current results
132+ return null ;
133+ }
94134
95135 if ( textEditor . getText ( ) !== text ) {
96136 // The editor contents have changed, tell Linter not to update
0 commit comments