From: Martin Quinson Date: Thu, 20 Sep 2018 20:40:09 +0000 (+0200) Subject: improve the error messages so that you can understand them without reading the source... X-Git-Tag: v3_21~62 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/463d221d6fb8f679b2b4eb41cb9c8aaf998d381b improve the error messages so that you can understand them without reading the source code --- 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();