MCPcopy Index your code
hub / github.com/extrabacon/python-shell / parseError

Method parseError

index.ts:367–386  ·  view source on GitHub ↗

* Parses an error thrown from the Python process through stderr * @param {string|Buffer} data The stderr contents to parse * @return {Error} The parsed error with extended stack trace when traceback is available

(data: string | Buffer)

Source from the content-addressed store, hash-verified

365 * @return {Error} The parsed error with extended stack trace when traceback is available
366 */
367 private parseError(data: string | Buffer) {
368 let text = '' + data;
369 let error: PythonShellError;
370
371 if (/^Traceback/.test(text)) {
372 // traceback data is available
373 let lines = text.trim().split(newline);
374 let exception = lines.pop();
375 error = new PythonShellError(exception);
376 error.traceback = data;
377 // extend stack trace
378 error.stack += newline + ' ----- Python Traceback -----' + newline + ' ';
379 error.stack += lines.slice(1).join(newline + ' ');
380 } else {
381 // otherwise, create a simpler error with stderr contents
382 error = new PythonShellError(text);
383 }
384
385 return error;
386 };
387
388 /**
389 * Sends a message to the Python shell through stdin

Callers 1

terminateIfNeededMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected