diff --git a/src/cmd.js b/src/cmd.js index 703eb97..2d7dae8 100644 --- a/src/cmd.js +++ b/src/cmd.js @@ -496,9 +496,12 @@ const get_value_explorer = (state, index) => { } if(frame.type == 'function_expr' && frame.body.type != 'do') { + const result = frame.children[1].result return { index: frame.children[1].index, - result: frame.children[1].result + result: result.ok + ? result + : find_error_origin_node(frame.children[1]).result } } diff --git a/test/test.js b/test/test.js index 1e01484..d336d8f 100644 --- a/test/test.js +++ b/test/test.js @@ -1794,6 +1794,22 @@ const y = x()` assert_equal(s2.effects.type, 'unembed_value_explorer') }), + test_only('move_cursor concise fn throws', () => { + const code = ` + const throws = () => { + throw new Error('boom') + } + + const x = () => 2 * (throws() + 1) + + x() + ` + const s1 = test_initial_state(code) + const {effects} = COMMANDS.move_cursor(s1, code.indexOf('throws()')) + assert_equal(effects.args[0].result.error.message, 'boom') + }), + + test('frame follows cursor toplevel', () => { const code = ` const x = () => {