Skip to content

Commit

Permalink
feat: Display whether an error happened during render or init
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed May 26, 2018
1 parent 1eb4edf commit d7276cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/base/base_component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ describe('Component', function() {
'render_func': my_render
})
my_render.should.be.called()
assert.equal(d3.select('p.error').text(), message)
assert.equal(d3.select('p.error').text(), message + ' [render]')
})

it(`error message when error happens during init() (${message})`, () => {
Expand All @@ -777,7 +777,7 @@ describe('Component', function() {
'has_init': true
})
my_init.should.be.called()
assert.equal(d3.select('p.error').text(), message)
assert.equal(d3.select('p.error').text(), message + ' [bind]')
})
})
})
2 changes: 1 addition & 1 deletion src/components/base/bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const create_element = (init_func, instance_args, selection) => {
return (typeof init_func === 'function')
? init_func(instance_args, selection) : selection.append('span')
} catch(error) {
selection.call(show_error_message(error))
selection.call(show_error_message(`${error} [bind]`))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/base/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const call_render_function = (args, instance_args, selection, element) =>
args.render(instance_args, selection, format_data(instance_args, data),
element, data)
} catch (error) {
selection.call(show_error_message(error))
selection.call(show_error_message(`${error} [render]`))
}
}

Expand All @@ -23,7 +23,7 @@ const render_component_with_query = (args, instance_args, selection,
element) => (data) =>
with_spinner(selection)(
execute_query(instance_args.query, data)(
e => show_error_message(e)(selection)))(
e => show_error_message(`${e} [render]`)(selection)))(
call_render_function(args, instance_args, selection, element))

const has_query = (instance_args) =>
Expand Down

0 comments on commit d7276cd

Please sign in to comment.