def raise_for_execution_errors(nb, output_path):
error = None<EOL>for cell in nb.cells:<EOL><INDENT>if cell.get("<STR_LIT>") is None:<EOL><INDENT>continue<EOL><DEDENT>for output in cell.outputs:<EOL><INDENT>if output.output_type == "<STR_LIT:error>":<EOL><INDENT>error = PapermillExecutionError(<EOL>exec_count=cell.execution_count,<EOL>source=cell.source,<EOL>ename=output.ename,<EOL>evalue=output.evalue,<EOL>traceback=output.traceback,<EOL>)<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if error:<EOL><INDENT>error_msg = ERROR_MESSAGE_TEMPLATE % str(error.exec_count)<EOL>error_msg_cell = nbformat.v4.new_code_cell(<EOL>source="<STR_LIT>" + error_msg,<EOL>outputs=[<EOL>nbformat.v4.new_output(output_type="<STR_LIT>", data={"<STR_LIT>": error_msg})<EOL>],<EOL>metadata={"<STR_LIT>": True, "<STR_LIT>": True},<EOL>)<EOL>nb.cells = [error_msg_cell] + nb.cells<EOL>write_ipynb(nb, output_path)<EOL>raise error<EOL><DEDENT>
Assigned parameters into the appropriate place in the input notebook

    Parameters
    ----------
    nb : NotebookNode
       Executable notebook object
    output_path : str
       Path to write executed notebook