Add optional error boundary support#473
Conversation
b656cc0 to
bd1badb
Compare
|
Ok @Daniel15 this is ready for review |
|
@Daniel15 would you have time to take a look at this PR soon? Are you OK with the overall direction? |
Daniel15
left a comment
There was a problem hiding this comment.
Sorry for the delay! In general, this looks pretty good to me.
src/React.Core/ReactComponent.cs
Outdated
| catch (JsRuntimeException ex) | ||
| { | ||
| attributes += string.Format(" class=\"{0}\"", ContainerClass); | ||
| if (_configuration.ExceptionHandler == null) { |
There was a problem hiding this comment.
I wonder if we should also allow setting an exception handler per component (eg. as an argument to this method). Hmm.
src/React.Core/ReactComponent.cs
Outdated
| catch (JsRuntimeException ex) | ||
| { | ||
| attributes += string.Format(" class=\"{0}\"", ContainerClass); | ||
| if (_configuration.ExceptionHandler == null) { |
There was a problem hiding this comment.
Instead of checking if this is null, what about making it the default handler? That way, _configuration.ExceptionHandler would never be null.
src/React.Core/ReactComponent.cs
Outdated
| ContainerId | ||
| )); | ||
| } | ||
| _configuration.ExceptionHandler(ex); |
There was a problem hiding this comment.
Might be worth passing ComponentName and ContainerId too.
|
Thanks for the review, I'll push an update soon :) |
b2c4997 to
4ef3074
Compare
4ef3074 to
46b45b3
Compare
a6ceeab to
13c9926
Compare
|
@Daniel15 this should be good to go, want to give it another look? |
I updated a sample so you can see how this works. When specifying an error handler, then errors will be caught during server-render (including those not handled by error boundaries).
Some tests still need to be added, but I wanted to get the discussion started about this approach.