1 #include "../icedb/error.hpp" 2 #include "../private/options.hpp" 3 #include "../icedb/error_context.h" 4 #include "../icedb/error.h" 5 #include "../icedb/util.h" 26 const size_t buf_size = 1000;
32 const char* sep =
"\t%s\t=\t%s\n";
33 const size_t seplen = strlen(sep);
35 #ifdef ICEDB_USING_SECURE_STRINGS 40 size_t expectedSize = 0;
47 char *tempbuf = (
char*)
ICEDB_malloc(
sizeof(
char)*expectedSize);
72 const char* sep =
"\t%s\t=\t%s\n";
73 const size_t seplen = strlen(sep);
75 #ifdef ICEDB_USING_SECURE_STRINGS 80 size_t expectedSize = 0;
87 char *tempbuf = (
char*)
ICEDB_malloc(
sizeof(
char)*expectedSize);
113 printf(
"Error in writing error context to stream. Error code is %d. Context text is: %s.\n",
122 return uint16_t(res);
150 return size_t((res>SIZE_MAX) ? SIZE_MAX : res);
187 #if defined(__FreeBSD__) 189 #elif defined(__NetBSD__) 191 #elif defined(__OpenBSD__) 193 #elif defined(__bsdi__) 195 #elif defined(__DragonFly__) 197 #elif defined (__APPLE__) 199 #elif defined(__linux__) 201 #elif defined(_WIN32) 203 #elif defined(__unix__) 232 std::list<::icedb::registry::const_options_ptr>
stk;
245 std::ostringstream o;
246 o <<
"error: " <<
stringify(ep->et) << std::endl;
249 for (
const auto &e : ep->stk) {
250 o <<
"Throw frame " << i << std::endl;
254 ep->emessage = o.str();
255 return ep->emessage.c_str();
259 ep->stk.push_back(op);
266 ep->stk.push_back(op);
273 if (!ep->cur) push();
274 this->ep->cur->add<T>(key, value);
278 #define DOTYPES(f) f(int); f(float); f(double); f(long); f(long long); \ 279 f(unsigned int); f(unsigned long); f(unsigned long long); f(std::string); f(bool); f(std::complex<double>); 281 #define IMPL_xError_ADD(T) template xError& xError::add<T>(const std::string&, const T); 286 if (!ep->cur) push();
287 this->ep->cur->add<std::string>(key, std::string(value));
317 std::vector<char> buf(sz);
319 res = std::string(buf.data());
#define ICEDB_DEBUG_RAISE_EXCEPTION()
#define ICEDB_error_context_append_str
A convenience wrapper for all error functions.
ICEDB_SYMBOL_SHARED void ICEDB_free(void *obj)
Free memory region. Should not be double-freed.
DL_ICEDB ICEDB_error_context_to_message_f ICEDB_error_context_to_message
DL_ICEDB error_code_t error_context_to_code(const error_context_pt &err)
Not really an error, but used for counting.
DL_ICEDB ICEDB_error_code_to_stream_f ICEDB_error_code_to_stream
#define ICEDB_BEGIN_DECL_C
size_t error_context_to_message(const struct ICEDB_error_context *err, size_t buf_size, char *buf)
size_t error_code_to_message_size(ICEDB_error_code err)
std::shared_ptr< ICEDB_error_context > error_context_pt
virtual const char * what() const noexcept
DL_ICEDB const struct ICEDB_error_container_ftable ICEDB_ct_error
static std::shared_ptr< options > generate()
ICEDB_error_code error_code_t
size_t(* ICEDB_error_code_to_message_size_f)(ICEDB_error_code err)
DL_ICEDB ICEDB_error_context_to_message_size_f ICEDB_error_context_to_message_size
ICEDB_error_context_var_val * var_vals
size_t(* ICEDB_error_context_to_message_f)(const struct ICEDB_error_context *err, size_t buf_size, char *buf)
DL_ICEDB ICEDB_error_code_to_message_size_f ICEDB_error_code_to_message_size
DL_ICEDB ICEDB_error_getOSname_f ICEDB_error_getOSname
void error_context_deallocate(struct ICEDB_error_context *c)
size_t(* ICEDB_error_context_to_stream_f)(const struct ICEDB_error_context *err, FILE *fp)
size_t(* ICEDB_error_context_to_message_size_f)(const struct ICEDB_error_context *)
DL_ICEDB void stringify(error_code_t err, std::string &res)
DL_ICEDB ICEDB_error_code_to_message_f ICEDB_error_code_to_message
xError & add(const std::string &key, const T value)
ICEDB_BEGIN_DECL_C ICEDB_SYMBOL_SHARED size_t ICEDB_COMPAT_strncpy_s(char *dest, size_t destSz, const char *src, size_t srcSz)
struct ICEDB_error_context * get_error_context_thread_local_c()
size_t error_context_to_message_size(const struct ICEDB_error_context *err)
const char * error_getOSname()
#define IMPL_xError_ADD(T)
size_t error_code_to_message(ICEDB_error_code err, size_t buf_size, char *buf)
size_t error_context_to_stream(const struct ICEDB_error_context *err, FILE *fp)
DL_ICEDB error_context_pt get_error_context_thread_local()
DL_ICEDB ICEDB_error_test_f ICEDB_error_test
struct ICEDB_error_context *(* ICEDB_get_error_context_thread_local_f)()
ICEDB_error_code error_test()
DL_ICEDB ICEDB_error_context_to_code_f ICEDB_error_context_to_code
size_t error_code_to_stream(ICEDB_error_code err, FILE *fp)
ICEDB_SYMBOL_SHARED void * ICEDB_malloc(size_t numBytes)
Allocate memory in bytes. Generally this is just malloced, but a custom allocator may be substituted...
DL_ICEDB ICEDB_error_context_to_stream_f ICEDB_error_context_to_stream
std::shared_ptr< options > options_ptr
DL_ICEDB ICEDB_error_context_deallocate_f ICEDB_error_context_deallocate
ICEDB_SYMBOL_PRIVATE ICEDB_THREAD_LOCAL ICEDB_error_context * __ICEDB_LOCAL_THREAD_error_context
ICEDB_error_code(* ICEDB_error_test_f)()
xError(error_types=error_types::xOtherError)
size_t(* ICEDB_error_code_to_stream_f)(ICEDB_error_code err, FILE *fp)
const char *(* ICEDB_error_getOSname_f)()
Convenience function that returns an immutable string describing the OS type. Staticly allocated...
void(* ICEDB_error_context_deallocate_f)(struct ICEDB_error_context *)
ICEDB_SYMBOL_PRIVATE const char * ICEDB_ERRORCODES_MAP[ICEDB_ERRORCODES_TOTAL]
DL_ICEDB ICEDB_get_error_context_thread_local_f ICEDB_get_error_context_thread_local
size_t(* ICEDB_error_code_to_message_f)(ICEDB_error_code err, size_t buf_size, char *buf)
#define ICEDB_COMPAT_strnlen_s
#define ICEDB_COMPAT_fputs_s
ICEDB_error_code(* ICEDB_error_context_to_code_f)(const struct ICEDB_error_context *)
#define ICEDB_error_context_create(x)
::icedb::registry::options_ptr cur
ICEDB_BEGIN_DECL_C ICEDB_error_code error_context_to_code(const struct ICEDB_error_context *err)
#define ICEDB_COMPAT_fprintf_s
std::list<::icedb::registry::const_options_ptr > stk