Goby3  3.1.4
2024.02.22
exception.h
Go to the documentation of this file.
1 // Copyright 2013-2021:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef GOBY_MIDDLEWARE_FRONTSEAT_EXCEPTION_H
26 #define GOBY_MIDDLEWARE_FRONTSEAT_EXCEPTION_H
27 
28 #include "goby/exception.h"
30 
31 namespace goby
32 {
33 namespace middleware
34 {
35 namespace frontseat
36 {
38 {
39  public:
41  : goby::Exception("Unknown FrontSeatException"),
42  helm_err_(protobuf::ERROR_HELM_NONE),
43  is_helm_error_(false),
44  fs_err_(protobuf::ERROR_FRONTSEAT_NONE),
45  is_fs_error_(false)
46  {
47  }
48 
50  : goby::Exception(protobuf::HelmError_Name(err)),
51  helm_err_(err),
52  is_helm_error_(true),
53  fs_err_(protobuf::ERROR_FRONTSEAT_NONE),
54  is_fs_error_(false)
55  {
56  }
58  : goby::Exception(protobuf::FrontSeatError_Name(err)),
59  helm_err_(protobuf::ERROR_HELM_NONE),
60  is_helm_error_(false),
61  fs_err_(err),
62  is_fs_error_(true)
63 
64  {
65  }
66 
67  protobuf::HelmError helm_err() const { return helm_err_; }
68  bool is_helm_error() const { return is_helm_error_; }
69 
70  protobuf::FrontSeatError fs_err() const { return fs_err_; }
71  bool is_fs_error() const { return is_fs_error_; }
72 
73  private:
74  protobuf::HelmError helm_err_;
75  bool is_helm_error_;
76 
78  bool is_fs_error_;
79 };
80 
81 inline std::ostream& operator<<(std::ostream& os, const goby::middleware::frontseat::Exception& e)
82 {
83  if (e.is_helm_error())
84  os << "Error in the Helm: " << protobuf::HelmError_Name(e.helm_err());
85  else if (e.is_fs_error())
86  os << "Error in the Frontseat: " << protobuf::FrontSeatError_Name(e.fs_err());
87  else
88  os << "Unknown error.";
89  return os;
90 };
91 } // namespace frontseat
92 } // namespace middleware
93 } // namespace goby
94 
95 #endif
goby::middleware::frontseat::Exception::Exception
Exception()
Definition: exception.h:40
goby::middleware::frontseat::Exception::is_helm_error
bool is_helm_error() const
Definition: exception.h:68
goby::middleware::frontseat::Exception
Definition: exception.h:37
goby::middleware::frontseat::protobuf::FrontSeatError_Name
const ::std::string & FrontSeatError_Name(FrontSeatError value)
Definition: frontseat.pb.h:209
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::middleware::frontseat::protobuf::HelmError_Name
const ::std::string & HelmError_Name(HelmError value)
Definition: frontseat.pb.h:188
goby::util::e
constexpr T e
Definition: constants.h:35
frontseat.pb.h
goby::middleware::frontseat::Exception::fs_err
protobuf::FrontSeatError fs_err() const
Definition: exception.h:70
goby::middleware::frontseat::Exception::is_fs_error
bool is_fs_error() const
Definition: exception.h:71
goby::middleware::frontseat::protobuf::ERROR_HELM_NONE
@ ERROR_HELM_NONE
Definition: frontseat.pb.h:178
goby::middleware::frontseat::Exception::Exception
Exception(protobuf::HelmError err)
Definition: exception.h:49
goby::middleware::frontseat::Exception::helm_err
protobuf::HelmError helm_err() const
Definition: exception.h:67
goby::middleware::frontseat::protobuf::FrontSeatError
FrontSeatError
Definition: frontseat.pb.h:197
goby::middleware::frontseat::operator<<
std::ostream & operator<<(std::ostream &os, const goby::middleware::frontseat::Exception &e)
Definition: exception.h:81
goby::Exception
simple exception class for goby applications
Definition: exception.h:34
exception.h
goby::middleware::frontseat::Exception::Exception
Exception(protobuf::FrontSeatError err)
Definition: exception.h:57
goby::middleware::frontseat::protobuf::ERROR_FRONTSEAT_NONE
@ ERROR_FRONTSEAT_NONE
Definition: frontseat.pb.h:198
goby::middleware::frontseat::protobuf::HelmError
HelmError
Definition: frontseat.pb.h:177