/** Exception raised when something got canceled before completion */
class CancelException : public xbt_ex {
+public:
+ CancelException(simgrid::xbt::ThrowPoint throwpoint, std::string message)
+ : xbt_ex(std::move(throwpoint), std::move(message))
+ {
+ category = cancel_error;
+ }
};
} // namespace simgrid
status = MSG_HOST_FAILURE;
} catch (simgrid::TimeoutError& e) {
status = MSG_TIMEOUT;
- } catch (xbt_ex& e) {
- if (e.category == cancel_error)
- status = MSG_TASK_CANCELED;
- else
- throw;
+ } catch (simgrid::CancelException& e) {
+ status = MSG_TASK_CANCELED;
}
/* action ended, set comm and compute = nullptr, the actions is already destroyed in the main function */
ret = MSG_HOST_FAILURE;
} catch (simgrid::TimeoutError& e) {
ret = MSG_TIMEOUT;
+ } catch (simgrid::CancelException& e) {
+ ret = MSG_HOST_FAILURE;
} catch (xbt_ex& e) {
- switch (e.category) {
- case cancel_error:
- ret = MSG_HOST_FAILURE;
- break;
- case network_error:
+ if (e.category == network_error)
ret = MSG_TRANSFER_FAILURE;
- break;
- default:
+ else
throw;
- }
}
if (ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
simcall_comm_wait(comm, timeout);
} catch (simgrid::TimeoutError& e) {
ret = MSG_TIMEOUT;
- }
- catch (xbt_ex& e) {
- switch (e.category) {
- case cancel_error:
- ret = MSG_HOST_FAILURE;
- break;
- case network_error:
+ } catch (simgrid::CancelException& e) {
+ ret = MSG_HOST_FAILURE;
+ } catch (xbt_ex& e) {
+ if (e.category == network_error)
ret = MSG_TRANSFER_FAILURE;
- break;
- default:
+ else
throw;
- }
/* If the send failed, it is not used anymore */
t_simdata->setNotUsed();
case SIMIX_CANCELED:
XBT_DEBUG("SIMIX_execution_finished: execution canceled");
- SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
+ simcall->issuer->exception =
+ std::make_exception_ptr(simgrid::CancelException(XBT_THROW_POINT, "Execution Canceled"));
break;
case SIMIX_TIMEOUT:
SMX_EXCEPTION(simcall->issuer, io_error, 0, "IO failed");
break;
case SIMIX_CANCELED:
- SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
+ simcall->issuer->exception = std::make_exception_ptr(simgrid::CancelException(XBT_THROW_POINT, "I/O Canceled"));
break;
default:
xbt_die("Internal error in SIMIX_io_finish: unexpected synchro state %d", static_cast<int>(synchro->state_));
case SIMIX_CANCELED:
if (simcall->issuer == comm->dst_actor_)
- SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the sender");
+ simcall->issuer->exception = std::make_exception_ptr(
+ simgrid::CancelException(XBT_THROW_POINT, "Communication canceled by the sender"));
else
- SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the receiver");
+ simcall->issuer->exception = std::make_exception_ptr(
+ simgrid::CancelException(XBT_THROW_POINT, "Communication canceled by the receiver"));
break;
default:
} catch (simgrid::NetworkFailureException& e) {
e.value = rank;
simcall->issuer->exception = std::make_exception_ptr(e);
- } catch (xbt_ex& e) {
- if (e.category == cancel_error) {
- e.value = rank;
- simcall->issuer->exception = std::make_exception_ptr(e);
- } else {
- xbt_die("Unexpected xbt_ex(%s). Please enhance this code", xbt_ex_catname(e.category));
- }
+ } catch (simgrid::CancelException& e) {
+ e.value = rank;
+ simcall->issuer->exception = std::make_exception_ptr(e);
}
}