From 316923481420292d88ced241dc5108f7240a34ab Mon Sep 17 00:00:00 2001 From: Steven Murray <Steven.Murray@cern.ch> Date: Sun, 14 Oct 2018 23:03:41 +0200 Subject: [PATCH] Acs::str2Volid() now throws InvalidVolid instead of InvalidAgument --- mediachanger/acs/Acs.cpp | 2 +- mediachanger/acs/Acs.hpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mediachanger/acs/Acs.cpp b/mediachanger/acs/Acs.cpp index 61f701ceb9..9e039e9245 100644 --- a/mediachanger/acs/Acs.cpp +++ b/mediachanger/acs/Acs.cpp @@ -50,7 +50,7 @@ DRIVEID cta::mediachanger::acs::Acs::alpd2DriveId(const uint32_t acs, //------------------------------------------------------------------------------ VOLID cta::mediachanger::acs::Acs::str2Volid(const std::string &str) { if(EXTERNAL_LABEL_SIZE < str.length()) { - cta::exception::InvalidArgument ex; + InvalidVolid ex; ex.getMessage() << "Failed to convert string to volume identifier" ": String is longer than the " << EXTERNAL_LABEL_SIZE << " character maximum"; diff --git a/mediachanger/acs/Acs.hpp b/mediachanger/acs/Acs.hpp index 5cb1ccaa65..a334210813 100644 --- a/mediachanger/acs/Acs.hpp +++ b/mediachanger/acs/Acs.hpp @@ -18,7 +18,8 @@ #pragma once -#include "common/exception/InvalidArgument.hpp" +#include "common/exception/Exception.hpp" + extern "C" { #include "acssys.h" #include "acsapi.h" @@ -55,14 +56,20 @@ public: static DRIVEID alpd2DriveId(const uint32_t acs, const uint32_t lsm, const uint32_t panel, const uint32_t drive); + /** + * Invalid volume identifier. + */ + struct InvalidVolid: public exception::Exception { + InvalidVolid(const std::string &context = "", const bool embedBacktrace = true): + cta::exception::Exception(context, embedBacktrace) {} + }; + /** * Returns the VOLID equibvalent of the specified string. * - * This method throws a cta::exception::InvalidArgument if the string is - * longer than EXTERNAL_LABEL_SIZE. - * * @param str The string representation of the volume identifier. * @return The VOLID representation of the volume identifier. + * @throw InvalidVolid if the string is longer than EXTERNAL_LABEL_SIZE. */ static VOLID str2Volid(const std::string &str); -- GitLab