File indexing completed on 2025-01-30 10:10:13
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <string>
0012
0013 namespace gloo {
0014 namespace transport {
0015 namespace tcp {
0016
0017 class Error {
0018 public:
0019
0020 static const Error kSuccess;
0021
0022 Error() : valid_(false) {}
0023
0024 virtual ~Error() = default;
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 operator bool() const {
0035 return valid_;
0036 }
0037
0038
0039
0040 virtual std::string what() const;
0041
0042 protected:
0043 explicit Error(bool valid) : valid_(valid) {}
0044
0045 private:
0046 const bool valid_;
0047 };
0048
0049 class SystemError : public Error {
0050 public:
0051 explicit SystemError(const char* syscall, int error)
0052 : Error(true), syscall_(syscall), error_(error) {}
0053
0054 std::string what() const override;
0055
0056 private:
0057 const char* syscall_;
0058 const int error_;
0059 };
0060
0061 class ShortReadError : public Error {
0062 public:
0063 ShortReadError(ssize_t expected, ssize_t actual)
0064 : Error(true), expected_(expected), actual_(actual) {}
0065
0066 std::string what() const override;
0067
0068 private:
0069 const ssize_t expected_;
0070 const ssize_t actual_;
0071 };
0072
0073 class ShortWriteError : public Error {
0074 public:
0075 ShortWriteError(ssize_t expected, ssize_t actual)
0076 : Error(true), expected_(expected), actual_(actual) {}
0077
0078 std::string what() const override;
0079
0080 private:
0081 const ssize_t expected_;
0082 const ssize_t actual_;
0083 };
0084
0085 }
0086 }
0087 }