@@ -120,39 +120,42 @@ public virtual string RenderHtml(bool renderContainerOnly = false, bool renderSe
120
120
EnsureComponentExists ( ) ;
121
121
}
122
122
123
- try
123
+ var html = string . Empty ;
124
+ if ( ! renderContainerOnly )
124
125
{
125
- var html = string . Empty ;
126
- if ( ! renderContainerOnly )
126
+ try
127
127
{
128
128
var reactRenderCommand = renderServerOnly
129
129
? string . Format ( "ReactDOMServer.renderToStaticMarkup({0})" , GetComponentInitialiser ( ) )
130
130
: string . Format ( "ReactDOMServer.renderToString({0})" , GetComponentInitialiser ( ) ) ;
131
131
html = _environment . Execute < string > ( reactRenderCommand ) ;
132
132
}
133
-
134
- string attributes = string . Format ( "id=\" {0}\" " , ContainerId ) ;
135
- if ( ! string . IsNullOrEmpty ( ContainerClass ) )
133
+ catch ( JsRuntimeException ex )
136
134
{
137
- attributes += string . Format ( " class=\" {0}\" " , ContainerClass ) ;
135
+ if ( _configuration . HandleRenderException == null ) {
136
+ throw new ReactServerRenderingException ( string . Format (
137
+ "Error while rendering \" {0}\" to \" {2}\" : {1}" ,
138
+ ComponentName ,
139
+ ex . Message ,
140
+ ContainerId
141
+ ) ) ;
142
+ }
143
+ _configuration . HandleRenderException ( ex ) ;
138
144
}
139
-
140
- return string . Format (
141
- "<{2} {0}>{1}</{2}>" ,
142
- attributes ,
143
- html ,
144
- ContainerTag
145
- ) ;
146
145
}
147
- catch ( JsRuntimeException ex )
146
+
147
+ string attributes = string . Format ( "id=\" {0}\" " , ContainerId ) ;
148
+ if ( ! string . IsNullOrEmpty ( ContainerClass ) )
148
149
{
149
- throw new ReactServerRenderingException ( string . Format (
150
- "Error while rendering \" {0}\" to \" {2}\" : {1}" ,
151
- ComponentName ,
152
- ex . Message ,
153
- ContainerId
154
- ) ) ;
150
+ attributes += string . Format ( " class=\" {0}\" " , ContainerClass ) ;
155
151
}
152
+
153
+ return string . Format (
154
+ "<{2} {0}>{1}</{2}>" ,
155
+ attributes ,
156
+ html ,
157
+ ContainerTag
158
+ ) ;
156
159
}
157
160
158
161
/// <summary>
0 commit comments