@@ -62,7 +62,7 @@ export interface Options extends SpawnOptions {
6262 args ?: string [ ]
6363}
6464
65- export class PythonError extends Error {
65+ export class PythonShellError extends Error {
6666 traceback : string | Buffer ;
6767 exitCode ?: number ;
6868}
@@ -90,7 +90,7 @@ export class PythonShell extends EventEmitter {
9090 private stderrHasEnded : boolean ;
9191 private stdoutHasEnded : boolean ;
9292 private _remaining : string
93- private _endCallback : ( err : PythonError , exitCode : number , exitSignal : string ) => any
93+ private _endCallback : ( err : PythonShellError , exitCode : number , exitSignal : string ) => any
9494
9595 // starting 2020 python2 is deprecated so we choose 3 as default
9696 static defaultPythonPath = process . platform != "win32" ? "python3" : "python" ;
@@ -190,14 +190,14 @@ export class PythonShell extends EventEmitter {
190190 function terminateIfNeeded ( ) {
191191 if ( ! self . stderrHasEnded || ! self . stdoutHasEnded || ( self . exitCode == null && self . exitSignal == null ) ) return ;
192192
193- let err : PythonError ;
193+ let err : PythonShellError ;
194194 if ( self . exitCode && self . exitCode !== 0 ) {
195195 if ( errorData ) {
196196 err = self . parseError ( errorData ) ;
197197 } else {
198- err = new PythonError ( 'process exited with code ' + self . exitCode ) ;
198+ err = new PythonShellError ( 'process exited with code ' + self . exitCode ) ;
199199 }
200- err = < PythonError > extend ( err , {
200+ err = < PythonShellError > extend ( err , {
201201 executable : pythonPath ,
202202 options : pythonOptions . length ? pythonOptions : null ,
203203 script : self . scriptPath ,
@@ -273,7 +273,7 @@ export class PythonShell extends EventEmitter {
273273 * @param {Function } callback The callback function to invoke with the script results
274274 * @return {PythonShell } The PythonShell instance
275275 */
276- static run ( scriptPath : string , options ?: Options , callback ?: ( err ?: PythonError , output ?: any [ ] ) => any ) {
276+ static run ( scriptPath : string , options ?: Options , callback ?: ( err ?: PythonShellError , output ?: any [ ] ) => any ) {
277277 let pyshell = new PythonShell ( scriptPath , options ) ;
278278 let output = [ ] ;
279279
@@ -291,7 +291,7 @@ export class PythonShell extends EventEmitter {
291291 * @param {Function } callback The callback function to invoke with the script results
292292 * @return {PythonShell } The PythonShell instance
293293 */
294- static runString ( code : string , options ?: Options , callback ?: ( err : PythonError , output ?: any [ ] ) => any ) {
294+ static runString ( code : string , options ?: Options , callback ?: ( err : PythonShellError , output ?: any [ ] ) => any ) {
295295
296296 // put code in temp file
297297 const randomInt = getRandomInt ( ) ;
@@ -318,20 +318,20 @@ export class PythonShell extends EventEmitter {
318318 */
319319 private parseError ( data : string | Buffer ) {
320320 let text = '' + data ;
321- let error : PythonError ;
321+ let error : PythonShellError ;
322322
323323 if ( / ^ T r a c e b a c k / . test ( text ) ) {
324324 // traceback data is available
325325 let lines = text . trim ( ) . split ( newline ) ;
326326 let exception = lines . pop ( ) ;
327- error = new PythonError ( exception ) ;
327+ error = new PythonShellError ( exception ) ;
328328 error . traceback = data ;
329329 // extend stack trace
330330 error . stack += newline + ' ----- Python Traceback -----' + newline + ' ' ;
331331 error . stack += lines . slice ( 1 ) . join ( newline + ' ' ) ;
332332 } else {
333333 // otherwise, create a simpler error with stderr contents
334- error = new PythonError ( text ) ;
334+ error = new PythonShellError ( text ) ;
335335 }
336336
337337 return error ;
@@ -399,7 +399,7 @@ export class PythonShell extends EventEmitter {
399399 * this should cause the process to finish its work and close.
400400 * @returns {PythonShell } The same instance for chaining calls
401401 */
402- end ( callback : ( err : PythonError , exitCode : number , exitSignal : string ) => any ) {
402+ end ( callback : ( err : PythonShellError , exitCode : number , exitSignal : string ) => any ) {
403403 if ( this . childProcess . stdin ) {
404404 this . childProcess . stdin . end ( ) ;
405405 }
@@ -464,10 +464,10 @@ export interface PythonShell {
464464 prependListener ( event : "error" , listener : ( error : NodeJS . ErrnoException ) => void ) : this;
465465 prependOnceListener ( event : "error" , listener : ( error : NodeJS . ErrnoException ) => void ) : this;
466466
467- addListener ( event : "pythonError" , listener : ( error : PythonError ) => void ) : this;
468- emit ( event : "pythonError" , error : PythonError ) : boolean ;
469- on ( event : "pythonError" , listener : ( error : PythonError ) => void ) : this;
470- once ( event : "pythonError" , listener : ( error : PythonError ) => void ) : this;
471- prependListener ( event : "pythonError" , listener : ( error : PythonError ) => void ) : this;
472- prependOnceListener ( event : "pythonError" , listener : ( error : PythonError ) => void ) : this;
467+ addListener ( event : "pythonError" , listener : ( error : PythonShellError ) => void ) : this;
468+ emit ( event : "pythonError" , error : PythonShellError ) : boolean ;
469+ on ( event : "pythonError" , listener : ( error : PythonShellError ) => void ) : this;
470+ once ( event : "pythonError" , listener : ( error : PythonShellError ) => void ) : this;
471+ prependListener ( event : "pythonError" , listener : ( error : PythonShellError ) => void ) : this;
472+ prependOnceListener ( event : "pythonError" , listener : ( error : PythonShellError ) => void ) : this;
473473}
0 commit comments