Unverified Commit 534111c7 authored by Jeremy Tuloup's avatar Jeremy Tuloup Committed by GitHub
Browse files

Merge pull request #78 from jtpio/errors

Improve error handling in pyolite
parents b3c2ca2f eabee206
......@@ -78,19 +78,7 @@ export class PyoliteKernel extends BaseKernel implements IKernel {
break;
}
case 'stderr': {
const { name, stack, message } = msg.stderr;
const error = {
name,
stack,
message
};
if (msg.error) {
this._executeDelegate.resolve({
...error,
parentHeader
});
break;
}
const { message } = msg.stderr;
const content = {
event: 'stream',
name: 'stderr',
......@@ -105,6 +93,19 @@ export class PyoliteKernel extends BaseKernel implements IKernel {
this._executeDelegate.resolve(bundle);
break;
}
case 'error': {
const { name, stack, message } = msg.error;
const error = {
name,
stack,
message
};
this._executeDelegate.resolve({
...error,
parentHeader
});
break;
}
case 'display': {
const bundle = msg.bundle ?? { data: {}, metadata: {} };
this.displayData(bundle);
......
......@@ -96,11 +96,11 @@ self.onmessage = async (event: MessageEvent): Promise<void> => {
let res;
try {
res = await interpreter.run(data.code);
} catch (err) {
} catch (error) {
postMessage({
parentheader: data.parentheader,
type: 'stderr',
stderr: err
type: 'error',
error
});
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment