GCC Code Coverage Report


Directory: ./
File: ecapp/Exceptions.h
Date: 2026-09-03 16:05:57
Exec Total Coverage
Lines: 8 8 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * This file is part of the ecapp library (EtherCAT application devices).
4 *
5 * Copyright (C) 2026 Florian Pose <fp@igh.de>
6 *
7 * The ecapp library is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation, version 3 of the
10 * License.
11 *
12 * The ecapp library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with the ecapp library. If not, see
19 * <https://www.gnu.org/licenses/>.
20 *
21 ****************************************************************************/
22
23 #ifndef ECAPP_EXCEPTIONS_H
24 #define ECAPP_EXCEPTIONS_H
25
26 /****************************************************************************/
27
28 #include "ecapp_export.h"
29
30 #include <stdexcept>
31 #include <string>
32
33 /****************************************************************************/
34
35 namespace EcApp {
36
37 /** Base class for all exceptions thrown by ecapp. */
38 15 class ECAPP_EXPORT Error : public std::runtime_error
39 {
40 public:
41 15 explicit Error(const std::string &what) : std::runtime_error(what) {}
42 };
43
44 /** Thrown by createSubDevice() when no registered device matches the
45 * requested name, or vendor/product/revision combination. */
46 6 class ECAPP_EXPORT UnknownDevice : public Error
47 {
48 public:
49 6 explicit UnknownDevice(const std::string &what) : Error(what) {}
50 };
51
52 /** Thrown by SubDevice::inputIndex()/outputIndex() when no channel with
53 * the requested name exists on this device. */
54 8 class ECAPP_EXPORT UnknownChannel : public Error
55 {
56 public:
57 8 explicit UnknownChannel(const std::string &what) : Error(what) {}
58 };
59
60 /** Thrown by capability() when a device does not implement the requested
61 * capability interface (e.g. setInputType() on a device without
62 * switchable analog ranges). Wrong-type channel access instead throws
63 * std::bad_variant_access from ChannelValue itself. */
64 1 class ECAPP_EXPORT UnsupportedCapability : public Error
65 {
66 public:
67 1 explicit UnsupportedCapability(const std::string &what) : Error(what) {}
68 };
69
70 } // namespace EcApp
71
72 #endif // ECAPP_EXCEPTIONS_H
73
74 /****************************************************************************/
75