From 463d221d6fb8f679b2b4eb41cb9c8aaf998d381b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 20 Sep 2018 22:40:09 +0200 Subject: [PATCH 1/1] improve the error messages so that you can understand them without reading the source code --- src/s4u/s4u_Comm.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 14741370c9..aed053d988 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -59,27 +59,31 @@ void Comm::wait_all(std::vector* comms) Activity* Comm::set_rate(double rate) { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); rate_ = rate; return this; } Activity* Comm::set_src_data(void* buff) { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); xbt_assert(dst_buff_ == nullptr, "Cannot set the src and dst buffers at the same time"); src_buff_ = buff; return this; } Activity* Comm::set_src_data_size(size_t size) { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); src_buff_size_ = size; return this; } Activity* Comm::set_src_data(void* buff, size_t size) { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); xbt_assert(dst_buff_ == nullptr, "Cannot set the src and dst buffers at the same time"); src_buff_ = buff; @@ -88,19 +92,21 @@ Activity* Comm::set_src_data(void* buff, size_t size) } Activity* Comm::set_dst_data(void** buff) { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); xbt_assert(src_buff_ == nullptr, "Cannot set the src and dst buffers at the same time"); dst_buff_ = buff; return this; } size_t Comm::get_dst_data_size() { - xbt_assert(state_ == State::FINISHED); + xbt_assert(state_ == State::FINISHED, "You cannot use %s before your communication terminated", __FUNCTION__); return dst_buff_size_; } Activity* Comm::set_dst_data(void** buff, size_t size) { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); xbt_assert(src_buff_ == nullptr, "Cannot set the src and dst buffers at the same time"); dst_buff_ = buff; @@ -110,7 +116,8 @@ Activity* Comm::set_dst_data(void** buff, size_t size) Activity* Comm::start() { - xbt_assert(state_ == State::INITED); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); if (src_buff_ != nullptr) { // Sender side on_sender_start(Actor::self()); @@ -185,7 +192,8 @@ int Comm::test_any(std::vector* comms) Activity* Comm::detach() { - xbt_assert(state_ == State::INITED, "You cannot detach communications once they are started (not implemented)."); + xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)", + __FUNCTION__); xbt_assert(src_buff_ != nullptr && src_buff_size_ != 0, "You can only detach sends, not recvs"); detached_ = true; return start(); -- 2.20.1