From 4141cd9660259caa66e2e9af10873e53402b4812 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 18 Feb 2019 23:01:04 +0100 Subject: [PATCH 1/1] add a StorageFailureException --- include/simgrid/Exception.hpp | 10 ++++++++++ src/kernel/activity/IoImpl.cpp | 1 + src/simix/smx_io.cpp | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/simgrid/Exception.hpp b/include/simgrid/Exception.hpp index b414b15f8b..a0786a9df8 100644 --- a/include/simgrid/Exception.hpp +++ b/include/simgrid/Exception.hpp @@ -144,6 +144,16 @@ public: } }; +/** Exception raised when a storage fails */ +class StorageFailureException : public xbt_ex { +public: + StorageFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) + : xbt_ex(std::move(throwpoint), std::move(message)) + { + category = io_error; + } +}; + /** Exception raised when something got canceled before completion */ class CancelException : public xbt_ex { public: diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 0f8a3ed701..5fac5af006 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -43,6 +43,7 @@ void IoImpl::cancel() XBT_VERB("This exec %p is canceled", this); if (surf_action_ != nullptr) surf_action_->cancel(); + state_ = SIMIX_CANCELED; } double IoImpl::get_remaining() diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index 62e482f7c2..4b8ecbc42f 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -44,7 +44,8 @@ void SIMIX_io_finish(smx_activity_t synchro) /* do nothing, synchro done */ break; case SIMIX_FAILED: - SMX_EXCEPTION(simcall->issuer, io_error, 0, "IO failed"); + simcall->issuer->exception_ = + std::make_exception_ptr(simgrid::StorageFailureException(XBT_THROW_POINT, "Storage failed")); break; case SIMIX_CANCELED: simcall->issuer->exception_ = -- 2.20.1