@@ -120,39 +120,42 @@ public virtual string RenderHtml(bool renderContainerOnly = false, bool renderSe
120120 EnsureComponentExists ( ) ;
121121 }
122122
123- try
123+ var html = string . Empty ;
124+ if ( ! renderContainerOnly )
124125 {
125- var html = string . Empty ;
126- if ( ! renderContainerOnly )
126+ try
127127 {
128128 var reactRenderCommand = renderServerOnly
129129 ? string . Format ( "ReactDOMServer.renderToStaticMarkup({0})" , GetComponentInitialiser ( ) )
130130 : string . Format ( "ReactDOMServer.renderToString({0})" , GetComponentInitialiser ( ) ) ;
131131 html = _environment . Execute < string > ( reactRenderCommand ) ;
132132 }
133-
134- string attributes = string . Format ( "id=\" {0}\" " , ContainerId ) ;
135- if ( ! string . IsNullOrEmpty ( ContainerClass ) )
133+ catch ( JsRuntimeException ex )
136134 {
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 ) ;
138144 }
139-
140- return string . Format (
141- "<{2} {0}>{1}</{2}>" ,
142- attributes ,
143- html ,
144- ContainerTag
145- ) ;
146145 }
147- catch ( JsRuntimeException ex )
146+
147+ string attributes = string . Format ( "id=\" {0}\" " , ContainerId ) ;
148+ if ( ! string . IsNullOrEmpty ( ContainerClass ) )
148149 {
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 ) ;
155151 }
152+
153+ return string . Format (
154+ "<{2} {0}>{1}</{2}>" ,
155+ attributes ,
156+ html ,
157+ ContainerTag
158+ ) ;
156159 }
157160
158161 /// <summary>
0 commit comments