SystemExceptions.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_EXCEPTION__SYSTEM_EXCEPTIONS
18 #define COM_BORA_SOFTWARE__BALAU_EXCEPTION__SYSTEM_EXCEPTIONS
19 
21 
22 namespace Balau::Exception {
23 
28  public: int errorNumber;
29 
30  protected: ErrNoException(const char * file,
31  int line,
32  const std::string & st,
33  int errorNumber_,
34  const std::string & name)
35  : BalauException(file, line, st, name, " - error: " + ::toString(errorNumber_))
36  , errorNumber(errorNumber_) {}
37 
38  protected: ErrNoException(const char * file,
39  int line,
40  const std::string & st,
41  int errorNumber_,
42  const std::string & name,
43  const std::string & message_)
44  : BalauException(file, line, st, name, " - error: " + ::toString(errorNumber_) + " - " + message_)
45  , errorNumber(errorNumber_) {}
46 };
47 
48 inline bool operator == (const ErrNoException & lhs, const ErrNoException & rhs) {
49  return typeid(lhs) == typeid(rhs) && lhs.message == rhs.message && lhs.errorNumber == rhs.errorNumber;
50 }
51 
58 class ForkException : public ErrNoException {
59  public: ForkException(const char * file,
60  int line,
61  const std::string & st,
62  int errorNumber_,
63  const std::string & message_)
64  : ErrNoException(file, line, st, errorNumber_, "Fork", message_) {}
65 };
66 
70 class WaitException : public ErrNoException {
71  public: WaitException(const char * file,
72  int line,
73  const std::string & st,
74  int errorNumber_,
75  const std::string & message_)
76  : ErrNoException(file, line, st, errorNumber_, "Wait", message_) {}
77 
78  public: WaitException(const char * file, int line, const std::string & st, int errorNumber_)
79  : ErrNoException(file, line, st, errorNumber_, "Wait") {}
80 };
81 
82 } // namespace Balau::Exception
83 
84 #endif // COM_BORA_SOFTWARE__BALAU_EXCEPTION__SYSTEM_EXCEPTIONS
bool operator==(const BalauException &lhs, const BalauException &rhs)
Base class comparison function for Balau exceptions.
Definition: BalauException.hpp:112
All exception classes.
Definition: BalauException.hpp:50
Balau::U8String< AllocatorT > toString(const BalauException &e)
Base class toString<AllocatorT> function for Balau exceptions.
Definition: BalauException.hpp:122
Abstract base class of exceptions that report errno.
Definition: SystemExceptions.hpp:27
const std::string message
The message.
Definition: BalauException.hpp:59
Thrown when a fork call fails.
Definition: SystemExceptions.hpp:58
Base Balau exception classes.
Thrown when a wait call fails.
Definition: SystemExceptions.hpp:70
Base class of all Balau exceptions.
Definition: BalauException.hpp:55