diff --git a/src/runtime2/component/component_pdl.rs b/src/runtime2/component/component_pdl.rs index 46424fe798589d6830b7a9877dfb6cf8e960a2bb..0e9bf987c38a1fcbc10e80cba1f1aff0b5f5df3d 100644 --- a/src/runtime2/component/component_pdl.rs +++ b/src/runtime2/component/component_pdl.rs @@ -260,7 +260,7 @@ impl Component for CompPDL { &mut self.exec_state, &mut self.control, &mut self.consensus, message, sched_ctx, comp_ctx ) { - self.handle_component_error(sched_ctx, location_and_message); + self.handle_generic_component_error(sched_ctx, location_and_message); } }, Message::Sync(message) => { @@ -297,15 +297,7 @@ impl Component for CompPDL { let run_result = self.execute_prompt(&sched_ctx); if let Err(error) = run_result { - // TODO: Cleanup before @nocommit - sched_ctx.error(&format!("{}", error)); - let exit_reason = if self.exec_state.mode.is_in_sync_block() { - ExitReason::ErrorInSync - } else { - ExitReason::ErrorNonSync - }; - - self.exec_state.set_as_start_exit(exit_reason); + self.handle_component_error(sched_ctx, CompError::Executor(error)); return CompScheduling::Immediate; } @@ -339,7 +331,7 @@ impl Component for CompPDL { comp_ctx, sched_ctx, &mut self.control ); if let Err(location_and_message) = receive_result { - self.handle_component_error(sched_ctx, location_and_message); + self.handle_generic_component_error(sched_ctx, location_and_message); return CompScheduling::Immediate } else { self.exec_ctx.stmt = ExecStmt::PerformedGet(message.content); @@ -367,7 +359,7 @@ impl Component for CompPDL { sched_ctx, &mut self.consensus, comp_ctx ); if let Err(location_and_message) = send_result { - self.handle_component_error(sched_ctx, location_and_message); + self.handle_generic_component_error(sched_ctx, location_and_message); return CompScheduling::Immediate; } else { // When `run` is called again (potentially after becoming @@ -571,7 +563,7 @@ impl CompPDL { /// Handles an error coming from the generic `component::handle_xxx` /// functions. Hence accepts argument as a tuple. - fn handle_component_error(&mut self, sched_ctx: &SchedulerCtx, location_and_message: (PortInstruction, String)) { + fn handle_generic_component_error(&mut self, sched_ctx: &SchedulerCtx, location_and_message: (PortInstruction, String)) { // Retrieve location and message, display in terminal let (location, message) = location_and_message; let error = match location { @@ -586,6 +578,10 @@ impl CompPDL { } }; + self.handle_component_error(sched_Ctx, error); + } + + fn handle_component_error(&mut self, sched_ctx: &SchedulerCtx, error: CompError) { sched_ctx.error(&format!("{}", error)); // Set state to handle subsequent error