本文整理汇总了C++中raise_exception函数的典型用法代码示例。如果您正苦于以下问题:C++ raise_exception函数的具体用法?C++ raise_exception怎么用?C++ raise_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了raise_exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_if_answer_is_complete
MODULE check_if_answer_is_complete (THREAD *thread)
{
Bool
complete;
tcb = thread-> tcb; /* Point to thread's context */
complete = rdns_check_answer_size (tcb-> query, (dbyte)tcb-> readsize);
if (complete == FALSE)
raise_exception (read_more_event);
}
示例2: helper_boundl
void helper_boundl(CPUX86State *env, target_ulong a0, int v)
{
int low, high;
low = cpu_ldl_data(env, a0);
high = cpu_ldl_data(env, a0 + 4);
if (v < low || v > high) {
raise_exception(env, EXCP05_BOUND);
}
}
示例3: raise_exception
const InputEventDefinition&
ControllerDescription::get_definition(int id) const
{
std::map<int, InputEventDefinition>::const_iterator i = id_to_event.find(id);
if (i == id_to_event.end())
{
raise_exception(std::runtime_error, "Unknown event id");
}
return i->second;
}
示例4: Java_org_zeromq_ZMQ_00024Socket_getLongSockopt
/**
* Called by Java's Socket::getLongSockopt(int option).
*/
JNIEXPORT jlong JNICALL Java_org_zeromq_ZMQ_00024Socket_getLongSockopt (JNIEnv *env,
jobject obj,
jint option)
{
switch (option) {
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(2,1,0)
case ZMQ_TYPE:
case ZMQ_FD:
case ZMQ_EVENTS:
case ZMQ_LINGER:
#endif
case ZMQ_HWM:
case ZMQ_SWAP:
case ZMQ_AFFINITY:
case ZMQ_RATE:
case ZMQ_RECOVERY_IVL:
case ZMQ_MCAST_LOOP:
case ZMQ_SNDBUF:
case ZMQ_RCVBUF:
case ZMQ_RCVMORE:
{
void *s = get_socket (env, obj, 1);
jlong ret = 0;
int rc = 0;
int err = 0;
uint64_t optval = 0;
size_t optvallen = sizeof(optval);
rc = zmq_getsockopt (s, option, &optval, &optvallen);
err = zmq_errno();
ret = (jlong) optval;
if (rc != 0) {
raise_exception (env, err);
return 0L;
}
return ret;
}
default:
raise_exception (env, EINVAL);
return 0L;
}
}
示例5: checkError
/** @brief Checks whether an OpenCL error has occured.
*
* Do not use this function directly, use the macro CL_ERROR_CHECK instead.
*/
static void checkError(cl_int err, const std::string & file, const std::string & func, int line)
{
if (err != CL_SUCCESS)
{
#ifdef VIENNACL_DEBUG_ALL
std::cerr << "ViennaCL: Error " << err << " in function " << func << " ( "<< file << ":" << line << " ) " << std::endl;
#endif
raise_exception(err);
}
} //checkError()
示例6: AerospikeScan_Results
PyObject * AerospikeScan_Results(AerospikeScan * self, PyObject * args, PyObject * kwds)
{
PyObject * py_policy = NULL;
as_policy_scan scan_policy;
as_policy_scan * scan_policy_p = NULL;
static char * kwlist[] = {"policy", NULL};
if ( PyArg_ParseTupleAndKeywords(args, kwds, "|O:results", kwlist, &py_policy) == false ) {
return NULL;
}
as_error err;
as_error_init(&err);
if (!self || !self->client->as) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Invalid aerospike object");
goto CLEANUP;
}
if (!self->client->is_conn_16) {
as_error_update(&err, AEROSPIKE_ERR_CLUSTER, "No connection to aerospike cluster");
goto CLEANUP;
}
// Convert python policy object to as_policy_scan
pyobject_to_policy_scan(&err, py_policy, &scan_policy, &scan_policy_p,
&self->client->as->config.policies.scan);
if ( err.code != AEROSPIKE_OK ) {
as_error_update(&err, err.code, NULL);
goto CLEANUP;
}
PyObject * py_results = NULL;
py_results = PyList_New(0);
PyThreadState * _save = PyEval_SaveThread();
aerospike_scan_foreach(self->client->as, &err, scan_policy_p, &self->scan, each_result, py_results);
PyEval_RestoreThread(_save);
CLEANUP:
if ( err.code != AEROSPIKE_OK ) {
PyObject * py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception(&err);
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
return NULL;
}
return py_results;
}
示例7: find_loader_by_filename
std::vector<std::string>
ArchiveManager::get_filenames(const std::string& zip_filename,
const ArchiveLoader** loader_out) const
{
auto loader = find_loader_by_filename(zip_filename);
if (!loader)
{
raise_exception(std::runtime_error, "failed to find loader for archive file: " << zip_filename);
}
else
{
try
{
if (loader_out) { *loader_out = loader; }
return loader->get_filenames(zip_filename);
}
catch(const std::exception& err)
{
auto new_loader = find_loader_by_magic(zip_filename);
if (!new_loader || new_loader == loader)
{
throw;
return std::vector<std::string>();
}
else
{
loader = new_loader;
if (!loader)
{
raise_exception(std::runtime_error, "failed to find loader for archive file: " << zip_filename);
}
else
{
log_warning << err.what() << std::endl;
if (loader_out) { *loader_out = loader; }
return loader->get_filenames(zip_filename);
}
}
}
}
}
示例8: log_info
void
System::create_dir(std::string directory)
{
#ifndef WIN32
log_info("System::create_dir: %1%", directory);
if (!exist(directory))
{
if (mkdir(directory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP) != 0)
{
raise_exception(std::runtime_error, "System::create_dir: " << directory << ": " << strerror(errno));
}
else
{
log_info("Successfully created: %1%", directory);
}
}
#else
if (!CreateDirectory(directory.c_str(), 0))
{
DWORD dwError = GetLastError();
if (dwError == ERROR_ALREADY_EXISTS)
{
}
else if (dwError == ERROR_PATH_NOT_FOUND)
{
raise_exception(std::runtime_error,
"CreateDirectory: " << directory <<
": One or more intermediate directories do not exist; this function will only create the final directory in the path.");
}
else
{
raise_exception(std::runtime_error,
"CreateDirectory: " << directory << ": failed with error " << StringUtil::to_string(dwError));
}
}
else
{
log_info("Successfully created: %1%", directory);
}
#endif
}
示例9: checkError
/** @brief Checks whether an OpenCL error has occured.
*
* Do not use this function directly, use the macro CL_ERROR_CHECK instead.
*/
static void checkError(cl_int err,
const std::string & file,
const std::string & func,
int line)
{
if (err != CL_SUCCESS)
{
std::cerr << "OpenCL: Error " << err << " in function " << func << " ( "<< file << ":" << line << " ) " << std::endl;
raise_exception(err);
}
} //checkError()
示例10: m_udev
UdevSubsystem::UdevSubsystem() :
m_udev(),
m_monitor(),
m_process_match_cb()
{
m_udev = udev_new();
if (!m_udev)
{
raise_exception(std::runtime_error, "udev init failure");
}
}
示例11: helper_rdpmc
void helper_rdpmc(CPUX86State *env)
{
if ((env->cr[4] & CR4_PCE_MASK) && ((env->hflags & HF_CPL_MASK) != 0)) {
raise_exception(env, EXCP0D_GPF);
}
cpu_svm_check_intercept_param(env, SVM_EXIT_RDPMC, 0);
/* currently unimplemented */
qemu_log_mask(LOG_UNIMP, "x86: unimplemented rdpmc\n");
raise_exception_err(env, EXCP06_ILLOP, 0);
}
示例12: music_sample
PingusSoundReal::PingusSoundReal() :
music_sample(0),
m_music_volume(1.0f),
m_sound_volume(1.0f),
m_master_volume(1.0f)
{
log_info("Initializing SDL audio");
if (SDL_Init(SDL_INIT_AUDIO) == -1)
{
raise_exception(std::runtime_error, "Unable to initialize SDL: " << SDL_GetError());
}
log_info("Initializing SDL_Mixer");
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) == -1)
{
raise_exception(std::runtime_error, "Unable to initialize SDL_Mixer: " << Mix_GetError());
}
}
示例13: mce_irq_ipi
static void mce_irq_ipi(void *info)
{
int cpu = smp_processor_id();
struct mce *m = this_cpu_ptr(&injectm);
if (cpumask_test_cpu(cpu, mce_inject_cpumask) &&
m->inject_flags & MCJ_EXCEPTION) {
cpumask_clear_cpu(cpu, mce_inject_cpumask);
raise_exception(m, NULL);
}
}
示例14: catch
PyObject *EntryIterator_iternext(PyObject *self)
{
EntryIterator *entryIterator = reinterpret_cast<EntryIterator *>(self);
bool notAtEnd;
Py_BEGIN_ALLOW_THREADS
try {
notAtEnd = entryIterator->iter->hasNext();
} catch (ac::IterationInterrupted &e) {
Py_BLOCK_THREADS
PyErr_SetNone(PyExc_GeneratorExit);
return NULL;
} catch (std::runtime_error &e) {
Py_BLOCK_THREADS
raise_exception(e.what());
return NULL;
}
Py_END_ALLOW_THREADS
if (notAtEnd) {
ac::Entry e;
Py_BEGIN_ALLOW_THREADS
try {
e = entryIterator->iter->next(*entryIterator->reader->reader);
} catch (ac::IterationInterrupted &e) {
Py_BLOCK_THREADS
// XXX - throw a specific exception here
PyErr_SetNone(PyExc_GeneratorExit);
return NULL;
} catch (std::runtime_error &e) {
Py_BLOCK_THREADS
raise_exception(e.what());
return NULL;
}
Py_END_ALLOW_THREADS
PyObject *entry = Entry_new(e);
return entry;
} else {
示例15: in
std::string
Filesystem::get_magic(const std::string& filename)
{
char buf[512];
std::ifstream in(filename, std::ios::binary);
if (!in)
{
raise_exception(std::runtime_error, filename << ": " << strerror(errno));
}
else
{
if (!in.read(buf, sizeof(buf)))
{
raise_exception(std::runtime_error, filename << ": " << strerror(errno));
}
else
{
return std::string(buf, in.gcount());
}
}
}