Skip to content

Commit

Permalink
injectCode now checks for an error and returns content.payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Fleming committed Feb 11, 2024
1 parent e246581 commit 293c0d3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/widgets/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,20 @@ export async function injectCode({
});
const future = connection.requestExecute({
code: code,
store_history: false
store_history: false,
stop_on_error: true,
silent: true,
allow_stdin: false
});
// TODO: Is there a better result to return?
return (await future.done) as any;
const result = (await future.done) as any;
if (result.content.status === 'ok') {
return result.content.payload;
} else {
throw new Error(
`Execution status = ${result.status} not 'ok' traceback=${result.content.traceback}`
);
}
}

/**
Expand Down

0 comments on commit 293c0d3

Please sign in to comment.