/usr/include/barry/error.h is in libbarry-dev 0.15-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | ///
/// \file error.h
/// Common exception classes for the Barry library
///
/*
Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License in the COPYING file at the
root directory of this project for more details.
*/
#ifndef __BARRY_ERROR_H__
#define __BARRY_ERROR_H__
#include "dll.h"
#include <stdexcept>
#include <stdint.h>
namespace Barry {
/// \addtogroup exceptions
/// @{
//
// Error class
//
/// The base class for any future derived exceptions.
/// Can be thrown on any protocol error.
///
class BXEXPORT Error : public std::runtime_error
{
public:
Error(const std::string &str) : std::runtime_error(str) {}
};
//
// BadPassword
//
/// A bad or unknown password when talking to the device.
/// Can be thrown in the following instances:
///
/// - no password provided and the device requests one
/// - device rejected the available password
/// - too few remaining tries left... Barry will refuse to keep
/// trying passwords if there are fewer than
/// BARRY_MIN_PASSWORD_TRIES tries remaining. In this case,
/// out_of_tries() will return true.
///
///
class BXEXPORT BadPassword : public Barry::Error
{
int m_remaining_tries;
bool m_out_of_tries;
public:
BadPassword(const std::string &str, int remaining_tries,
bool out_of_tries)
: Barry::Error(str),
m_remaining_tries(remaining_tries),
m_out_of_tries(out_of_tries)
{}
int remaining_tries() const { return m_remaining_tries; }
bool out_of_tries() const { return m_out_of_tries; }
};
//
// BadData
//
/// Thrown by record classes if their data is invalid and cannot be
/// uploaded to the Blackberry.
///
class BXEXPORT BadData : public Barry::Error
{
public:
BadData(const std::string &str)
: Barry::Error(str)
{}
};
//
// BadSize
//
/// Unexpected packet size, or not enough data.
///
class BXEXPORT BadSize : public Barry::Error
{
unsigned int m_packet_size,
m_data_buf_size,
m_required_size;
BXLOCAL static std::string GetMsg(const char *msg, unsigned int d, unsigned int r);
BXLOCAL static std::string GetMsg(unsigned int p, unsigned int d, unsigned int r);
public:
BadSize(const char *msg, unsigned int data_size, unsigned int required_size)
: Barry::Error(GetMsg(msg, data_size, required_size))
, m_packet_size(0)
, m_data_buf_size(data_size)
, m_required_size(required_size)
{}
BadSize(unsigned int packet_size,
unsigned int data_buf_size,
unsigned int required_size)
: Barry::Error(GetMsg(packet_size, data_buf_size, required_size))
, m_packet_size(packet_size)
, m_data_buf_size(data_buf_size)
, m_required_size(required_size)
{}
unsigned int packet_size() const { return m_packet_size; }
unsigned int data_buf_size() const { return m_data_buf_size; }
unsigned int required_size() const { return m_required_size; }
};
//
// ErrnoError
//
/// System error that provides an errno error code.
///
class BXEXPORT ErrnoError : public Barry::Error
{
int m_errno;
static std::string GetMsg(const std::string &msg, int err);
public:
ErrnoError(const std::string &msg, int err)
: Barry::Error(GetMsg(msg, err))
, m_errno(err)
{}
int error_code() const { return m_errno; }
};
//
// BadPackedFormat
//
/// Thrown by record classes that don't recognize a given packed format code.
/// This exception is mostly handled internally, but is published here
/// just in case it escapes.
///
class BXEXPORT BadPackedFormat : public Barry::Error
{
uint8_t m_format;
public:
BadPackedFormat(uint8_t format)
: Barry::Error("Bad packed format - internal exception")
, m_format(format)
{}
uint8_t format() const { return m_format; }
};
//
// BadPacket
//
/// Thrown by the socket class if a packet command's response indicates
/// an error. Some commands may be able to recover inside the library,
/// so a special exception is used, that includes the response code.
///
class BXEXPORT BadPacket : public Barry::Error
{
uint8_t m_response;
public:
BadPacket(uint8_t response, const std::string &msg)
: Barry::Error(msg)
, m_response(response)
{}
uint8_t response() const { return m_response; }
};
/// @}
} // namespace Barry
#endif
|