Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BARRY_ERROR_H__
00023 #define __BARRY_ERROR_H__
00024
00025 #include "dll.h"
00026 #include "pin.h"
00027 #include <stdexcept>
00028 #include <stdint.h>
00029
00030 namespace Barry {
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class BXEXPORT Error : public std::runtime_error
00042 {
00043 public:
00044 Error(const std::string &str) : std::runtime_error(str) {}
00045 };
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class BXEXPORT BadPassword : public Barry::Error
00063 {
00064 int m_remaining_tries;
00065 bool m_out_of_tries;
00066
00067 public:
00068 BadPassword(const std::string &str, int remaining_tries,
00069 bool out_of_tries)
00070 : Barry::Error(str),
00071 m_remaining_tries(remaining_tries),
00072 m_out_of_tries(out_of_tries)
00073 {}
00074 int remaining_tries() const { return m_remaining_tries; }
00075 bool out_of_tries() const { return m_out_of_tries; }
00076 };
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 class BXEXPORT SocketCloseOnOpen : public Barry::Error
00091 {
00092 public:
00093 SocketCloseOnOpen(const std::string &str) : Barry::Error(str) {}
00094 };
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 class BXEXPORT PinNotFound : public Barry::Error
00105 {
00106 Barry::Pin m_pin;
00107 int m_probe_count;
00108
00109 public:
00110 PinNotFound(Barry::Pin pin, int probe_count)
00111 : Barry::Error("PIN not found: " + pin.Str())
00112 , m_pin(pin)
00113 , m_probe_count(probe_count)
00114 {}
00115
00116 const Barry::Pin& pin() const { return m_pin; }
00117 int probe_count() const { return m_probe_count; }
00118 };
00119
00120
00121
00122
00123
00124
00125
00126 class BXEXPORT BadData : public Barry::Error
00127 {
00128 public:
00129 BadData(const std::string &str)
00130 : Barry::Error(str)
00131 {}
00132 };
00133
00134
00135
00136
00137
00138
00139 class BXEXPORT BadSize : public Barry::Error
00140 {
00141 unsigned int m_packet_size,
00142 m_data_buf_size,
00143 m_required_size;
00144
00145 BXLOCAL static std::string GetMsg(const char *msg, unsigned int d, unsigned int r);
00146 BXLOCAL static std::string GetMsg(unsigned int p, unsigned int d, unsigned int r);
00147
00148 public:
00149 BadSize(const char *msg, unsigned int data_size, unsigned int required_size);
00150 BadSize(unsigned int packet_size,
00151 unsigned int data_buf_size,
00152 unsigned int required_size);
00153 unsigned int packet_size() const { return m_packet_size; }
00154 unsigned int data_buf_size() const { return m_data_buf_size; }
00155 unsigned int required_size() const { return m_required_size; }
00156 };
00157
00158
00159
00160
00161
00162
00163 class BXEXPORT ErrnoError : public Barry::Error
00164 {
00165 int m_errno;
00166
00167 BXLOCAL static std::string GetMsg(const std::string &msg, int err);
00168
00169 protected:
00170 ErrnoError(const std::string &msg);
00171
00172 public:
00173 ErrnoError(const std::string &msg, int err);
00174
00175 int error_code() const { return m_errno; }
00176 };
00177
00178
00179
00180
00181
00182
00183
00184 class BXEXPORT ConfigFileError : public Barry::ErrnoError
00185 {
00186 public:
00187 ConfigFileError(const char *msg) : Barry::ErrnoError(msg) {}
00188 ConfigFileError(const char *msg, int err)
00189 : Barry::ErrnoError(msg, err)
00190 {}
00191 };
00192
00193
00194
00195
00196
00197
00198
00199
00200 class BXEXPORT BadPackedFormat : public Barry::Error
00201 {
00202 uint8_t m_format;
00203
00204 public:
00205 BadPackedFormat(uint8_t format)
00206 : Barry::Error("Bad packed format - internal exception")
00207 , m_format(format)
00208 {}
00209
00210 uint8_t format() const { return m_format; }
00211 };
00212
00213
00214
00215
00216
00217
00218
00219
00220 class BXEXPORT BadPacket : public Barry::Error
00221 {
00222 uint8_t m_response;
00223
00224 public:
00225 BadPacket(uint8_t response, const std::string &msg)
00226 : Barry::Error(msg)
00227 , m_response(response)
00228 {}
00229
00230 uint8_t response() const { return m_response; }
00231 };
00232
00233
00234
00235
00236
00237
00238 class BXEXPORT ConvertError : public Barry::Error
00239 {
00240 public:
00241 ConvertError(const std::string &msg) : Barry::Error(msg) {}
00242 };
00243
00244
00245
00246
00247
00248
00249
00250 class BXEXPORT BackupError : public Barry::Error
00251 {
00252 public:
00253 BackupError(const std::string &str) : Error(str) {}
00254 };
00255
00256
00257
00258
00259
00260
00261
00262 class BXEXPORT RestoreError : public Barry::Error
00263 {
00264 public:
00265 RestoreError(const std::string &str) : Error(str) {}
00266 };
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 class BXEXPORT ReturnCodeError : public Barry::Error
00278 {
00279 unsigned int m_command, m_return_code;
00280
00281 public:
00282 ReturnCodeError(const std::string &str, unsigned int command,
00283 unsigned int return_code)
00284 : Error(str)
00285 , m_command(command)
00286 , m_return_code(return_code)
00287 {
00288 }
00289
00290 unsigned int command() const { return m_command; }
00291 unsigned int return_code() const { return m_return_code; }
00292
00293 bool IsReadOnly() const { return return_code() == 0x02; }
00294 };
00295
00296
00297
00298
00299
00300
00301
00302 class BXEXPORT ValidationError : public Barry::Error
00303 {
00304 public:
00305 explicit ValidationError(const std::string &str)
00306 : Error(str)
00307 {
00308 }
00309 };
00310
00311
00312
00313 }
00314
00315 #endif
00316