From 62438bd99e2ec7d2fcedf01b0841fcefe93a20af Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Wed, 17 Mar 2021 12:34:24 +0100 Subject: [PATCH] shm: Improve error message when segment cannot be opened --- fairmq/shmem/Manager.h | 3 ++- fairmq/shmem/TransportFactory.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fairmq/shmem/Manager.h b/fairmq/shmem/Manager.h index a9b10732..2a7d9477 100644 --- a/fairmq/shmem/Manager.h +++ b/fairmq/shmem/Manager.h @@ -151,7 +151,8 @@ class Manager << " Allocation algorithm: " << allocationAlgorithm; LOG(debug) << ss.str(); } catch(interprocess_exception& bie) { - LOG(error) << "something went wrong: " << bie.what(); + LOG(error) << "Failed to create/open shared memory segment (" << "fmq_" << fShmId << "_m_" << fSegmentId << "): " << bie.what(); + throw std::runtime_error(tools::ToString("Failed to create/open shared memory segment (", "fmq_", fShmId, "_m_", fSegmentId, "): ", bie.what())); } if (mlockSegment) { diff --git a/fairmq/shmem/TransportFactory.h b/fairmq/shmem/TransportFactory.h index 85ef80dc..60f5e055 100644 --- a/fairmq/shmem/TransportFactory.h +++ b/fairmq/shmem/TransportFactory.h @@ -28,6 +28,7 @@ #include // unique_ptr, make_unique #include #include +#include namespace fair::mq::shmem { @@ -84,6 +85,9 @@ class TransportFactory final : public fair::mq::TransportFactory } catch (boost::interprocess::interprocess_exception& e) { LOG(error) << "Could not initialize shared memory transport: " << e.what(); throw std::runtime_error(tools::ToString("Could not initialize shared memory transport: ", e.what())); + } catch (const std::exception& e) { + LOG(error) << "Could not initialize shared memory transport: " << e.what(); + throw std::runtime_error(tools::ToString("Could not initialize shared memory transport: ", e.what())); } }