Skip to content

Commit 293c0d3

Browse files
author
Alan Fleming
committed
injectCode now checks for an error and returns content.payload
1 parent e246581 commit 293c0d3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/widgets/utils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,20 @@ export async function injectCode({
118118
});
119119
const future = connection.requestExecute({
120120
code: code,
121-
store_history: false
121+
store_history: false,
122+
stop_on_error: true,
123+
silent: true,
124+
allow_stdin: false
122125
});
123126
// TODO: Is there a better result to return?
124-
return (await future.done) as any;
127+
const result = (await future.done) as any;
128+
if (result.content.status === 'ok') {
129+
return result.content.payload;
130+
} else {
131+
throw new Error(
132+
`Execution status = ${result.status} not 'ok' traceback=${result.content.traceback}`
133+
);
134+
}
125135
}
126136

127137
/**

0 commit comments

Comments
 (0)