@@ -181,12 +181,27 @@ export default {
181181 const options = {
182182 stdin : fileText ,
183183 cwd : path . dirname ( textEditor . getPath ( ) ) ,
184- stream : 'both' ,
184+ ignoreExitCode : true ,
185185 timeout : forceTimeout ,
186186 uniqueKey : `linter-flake8:${ filePath } ` ,
187187 } ;
188188
189- const result = await helpers . exec ( execPath , parameters , options ) ;
189+ let result ;
190+ try {
191+ result = await helpers . exec ( execPath , parameters , options ) ;
192+ } catch ( e ) {
193+ const pyTrace = e . message . split ( '\n' ) ;
194+ const pyMostRecent = pyTrace [ pyTrace . length - 1 ] ;
195+ atom . notifications . addError ( 'Flake8 crashed!' , {
196+ detail : 'linter-flake8:: Flake8 threw an error related to:\n' +
197+ `${ pyMostRecent } \n` +
198+ "Please check Atom's Console for more details" ,
199+ } ) ;
200+ // eslint-disable-next-line no-console
201+ console . error ( 'linter-flake8:: Flake8 returned an error' , e . message ) ;
202+ // Tell Linter to not update any current messages it may have
203+ return null ;
204+ }
190205
191206 if ( result === null ) {
192207 // Process was killed by a future invocation
@@ -198,13 +213,9 @@ export default {
198213 return null ;
199214 }
200215
201- if ( result . stderr && result . stderr . length && atom . inDevMode ( ) ) {
202- // eslint-disable-next-line no-console
203- console . log ( `flake8 stderr: ${ result . stderr } ` ) ;
204- }
205216 const messages = [ ] ;
206217
207- let match = parseRegex . exec ( result . stdout ) ;
218+ let match = parseRegex . exec ( result ) ;
208219 while ( match !== null ) {
209220 // Note that these positions are being converted to 0-indexed
210221 const line = Number . parseInt ( match [ 1 ] , 10 ) - 1 || 0 ;
@@ -226,7 +237,7 @@ export default {
226237 execPath , match , filePath , textEditor , point ) ) ;
227238 }
228239
229- match = parseRegex . exec ( result . stdout ) ;
240+ match = parseRegex . exec ( result ) ;
230241 }
231242 // Ensure that any invalid point messages have finished resolving
232243 return Promise . all ( messages ) ;
0 commit comments