@@ -23,6 +23,15 @@ const loadDeps = () => {
23
23
}
24
24
} ;
25
25
26
+ const getCheckNotificationDetails = checkDetail =>
27
+ ( notification ) => {
28
+ const { detail } = notification . getOptions ( ) ;
29
+ if ( detail === checkDetail ) {
30
+ return true ;
31
+ }
32
+ return false ;
33
+ } ;
34
+
26
35
export default {
27
36
activate ( ) {
28
37
this . idleCallbacks = new Set ( ) ;
@@ -47,11 +56,15 @@ export default {
47
56
'linter-csslint.executablePath' ,
48
57
( value ) => { this . executablePath = value ; } ,
49
58
) ) ;
59
+
60
+ this . activeNotifications = new Set ( ) ;
50
61
} ,
51
62
52
63
deactivate ( ) {
53
64
this . idleCallbacks . forEach ( callbackID => window . cancelIdleCallback ( callbackID ) ) ;
54
65
this . idleCallbacks . clear ( ) ;
66
+ this . activeNotifications . forEach ( notification => notification . dismiss ( ) ) ;
67
+ this . activeNotifications . clear ( ) ;
55
68
this . subscriptions . dispose ( ) ;
56
69
} ,
57
70
@@ -90,7 +103,34 @@ export default {
90
103
91
104
const execPath = this . determineExecPath ( this . executablePath , projectPath ) ;
92
105
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
+ }
94
134
95
135
if ( textEditor . getText ( ) !== text ) {
96
136
// The editor contents have changed, tell Linter not to update
0 commit comments