/usr/include/vowpalwabbit/vw_exception.h is in libvw-dev 8.5.0.dfsg1-1.
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 | /*
Copyright (c) by respective owners including Yahoo!, Microsoft, and
individual contributors. All rights reserved. Released under a BSD (revised)
license as described in the file LICENSE.
*/
#pragma once
#include <stdexcept>
#include <sstream>
#ifndef _NOEXCEPT
// _NOEXCEPT is required on Mac OS
// making sure other platforms don't barf
#define _NOEXCEPT throw ()
#endif
namespace VW
{
class vw_exception : public std::exception
{
private:
// source file exception was thrown
const char* file;
std::string message;
// line number exception was thrown
int lineNumber;
public:
vw_exception(const char* file, int lineNumber, std::string message);
vw_exception(const vw_exception& ex);
~vw_exception() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
const char* Filename() const;
int LineNumber() const;
};
class vw_argument_disagreement_exception : public vw_exception
{
public:
vw_argument_disagreement_exception(const char* file, int lineNumber, std::string message);
vw_argument_disagreement_exception(const vw_argument_disagreement_exception& ex);
~vw_argument_disagreement_exception() _NOEXCEPT;
};
#ifdef _WIN32
void vw_trace(const char* filename, int linenumber, const char* fmt, ...);
// useful when hunting down release mode bugs
#define VW_TRACE(fmt, ...) VW::vw_trace(__FILE__, __LINE__, fmt, __VA_ARGS__)
struct StopWatchData;
class StopWatch
{ StopWatchData* data;
public:
StopWatch();
~StopWatch();
double MilliSeconds() const;
};
// Equivalent to System::Diagnostics::Debugger::Launch();
bool launchDebugger();
#define THROWERRNO(args) \
{ \
std::stringstream __msg; \
__msg << args; \
char __errmsg[256]; \
if (strerror_s(__errmsg, sizeof __errmsg, errno) != 0) \
__msg << ", errno = unknown"; \
else \
__msg << ", errno = " << __errmsg; \
throw VW::vw_exception(__FILE__, __LINE__, __msg.str()); \
}
#else
#define THROWERRNO(args) \
{ \
std::stringstream __msg; \
__msg << args; \
char __errmsg[256]; \
if (strerror_r(errno, __errmsg, sizeof __errmsg) != 0) \
__msg << "errno = unknown"; \
else \
__msg << "errno = " << __errmsg; \
throw VW::vw_exception(__FILE__, __LINE__, __msg.str()); \
}
#endif
// ease error handling and also log filename and line number
#define THROW(args) \
{ \
std::stringstream __msg; \
__msg << args; \
throw VW::vw_exception(__FILE__, __LINE__, __msg.str()); \
}
#define THROW_EX(ex, args) \
{ \
std::stringstream __msg; \
__msg << args; \
throw ex(__FILE__, __LINE__, __msg.str()); \
}
}
#define VW_ASSERT(condition, args) \
if (! (condition)) { \
THROW(args); \
}
|