peary/device/exceptions.hpp

Peary device exceptions. More…

Namespaces

Name
peary
peary::device

Classes

Name
class peary::device::DeviceError Base class for device-related errors.
class peary::device::InvalidInstanceError Exception class for running instance errors.
class peary::device::InvalidDeviceError Exception class for invalid device errors.
class peary::device::LibraryError Exception class for library errors.
class peary::device::DataAcquisitionError Exception class for data taking errors.

Detailed Description

Peary device exceptions.

Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only

Source code

  
#pragma once

#include <string_view>

#include "peary/utils/exceptions.hpp"

namespace peary::device {

    class DeviceError : public utils::RuntimeError {
    public:
        explicit DeviceError(std::string_view reason) : utils::RuntimeError(std::string(reason)) {}

    protected:
        DeviceError() = default;
    };

    class InvalidInstanceError : public DeviceError {
    public:
        explicit InvalidInstanceError(std::string_view name) {
            _message = "Found running instance of ";
            _message += name;
        }
    };

    class InvalidDeviceError : public DeviceError {
    public:
        explicit InvalidDeviceError(std::string_view device, std::string_view reason) {
            _message = "Invalid device ";
            _message += device;
            if(!reason.empty()) {
                _message += ": ";
                _message += reason;
            }
        }
    };

    class LibraryError : public DeviceError {
    public:
        explicit LibraryError(std::string_view reason) { _message = reason; }
    };

    class DataAcquisitionError : public DeviceError {
    public:
        explicit DataAcquisitionError(std::string_view reason) { _message = reason; }
    };

} // namespace peary::device
  

Updated on 2026-01-30 at 22:01:05 +0100