@@ -134,8 +134,9 @@ def generate_notebook_outputs(
134134 allow_errors = env .config ["execution_allow_errors" ],
135135 )
136136
137+ report_path = None
137138 if result .err :
138- message = _report_exec_fail (
139+ report_path , message = _report_exec_fail (
139140 env ,
140141 Path (file_path ).name ,
141142 result .exc_string ,
@@ -152,15 +153,19 @@ def generate_notebook_outputs(
152153 "method" : execution_method ,
153154 "succeeded" : False if result .err else True ,
154155 }
156+ if report_path :
157+ env .nb_execution_data [env .docname ]["error_log" ] = report_path
155158
156159 return ntbk
157160
158161 cache_base = get_cache (path_to_cache )
159162 # Use relpath here in case Sphinx is building from a non-parent folder
160163 r_file_path = Path (os .path .relpath (file_path , Path ().resolve ()))
161164
165+ # default execution data
162166 runtime = None
163167 succeeded = False
168+ report_path = None
164169
165170 try :
166171 pk , ntbk = cache_base .merge_match_into_notebook (ntbk )
@@ -174,13 +179,14 @@ def generate_notebook_outputs(
174179 except KeyError :
175180 stage_record = None
176181 if stage_record and stage_record .traceback :
177- message + = _report_exec_fail (
182+ report_path , suffix = _report_exec_fail (
178183 env ,
179184 r_file_path .name ,
180185 stage_record .traceback ,
181186 show_traceback ,
182187 "\n Last execution failed with traceback saved in {}" ,
183188 )
189+ message += suffix
184190
185191 LOGGER .error (message )
186192
@@ -207,6 +213,8 @@ def generate_notebook_outputs(
207213 "method" : execution_method ,
208214 "succeeded" : succeeded ,
209215 }
216+ if report_path :
217+ env .nb_execution_data [env .docname ]["error_log" ] = report_path
210218
211219 return ntbk
212220
@@ -233,7 +241,7 @@ def _report_exec_fail(
233241 message = template .format (full_path )
234242 if show_traceback :
235243 message += "\n " + traceback
236- return message
244+ return str ( full_path ), message
237245
238246
239247def _stage_and_execute (
0 commit comments