本文整理汇总了C++中throw_exception函数的典型用法代码示例。如果您正苦于以下问题:C++ throw_exception函数的具体用法?C++ throw_exception怎么用?C++ throw_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了throw_exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sr_set_item
void Session::set_item(const char *xpath, S_Val value, const sr_edit_options_t opts)
{
sr_val_t *val = value ? value->_val : nullptr;
int ret = sr_set_item(_sess, xpath, val, opts);
if (ret != SR_ERR_OK) {
throw_exception(ret);
}
}
示例2: throw_osxkeychainexception
/* Shorthand for throwing an OSXKeychainException from an OSStatus.
*
* Parameters:
* env The JNI environment.
* status The non-error status returned from a keychain call.
*/
void throw_osxkeychainexception(JNIEnv* env, OSStatus status) {
CFStringRef errorMessage = SecCopyErrorMessageString(status, NULL);
throw_exception(
env,
OSXKeychainException,
CFStringGetCStringPtr(errorMessage, kCFStringEncodingMacRoman)
);
CFRelease(errorMessage);
}
示例3: throw_exception
void Mesh_File_Reader::open()
{
// Checking the mesh path
if (!boost::filesystem::is_directory(_mesh_path))
{
throw_exception(IO_Error("Bad mesh path: '" + _mesh_path.string() +
"'"), FATAL_LEVEL, __FILE__, __LINE__);
}
}
示例4: throw_exception
bool expression_parser::is_name(any_regular_t& result) {
if (!is_token(at_k))
return false;
if (!is_token(keyword_k, result) && !is_token(identifier_k, result))
throw_exception("identifier or keyword required.");
return true;
}
示例5: result
void binspector_parser_t::require_identifier(adobe::name_t& name_result)
{
const adobe::stream_lex_token_t& result (get_token());
if (result.first != adobe::identifier_k)
throw_exception(adobe::identifier_k, result.first);
name_result = result.second.cast<adobe::name_t>();
}
示例6: malloc
/*
Edge "constructor". Constructs an edge from 2 vertices with
a given weight.
@param v1 First vertex this edge connects.
@param v2 Second vertex this edge connects.
@param weight Weight of the edge.
*/
edge_s *edge_s_ (vertex_s *v1, vertex_s *v2, double weight)
{
edge_s *edge;
edge = malloc(sizeof(*edge));
if (!edge)
throw_exception();
if (!(addedge(v1,edge) && addedge(v2,edge)))
throw_exception();
edge->v1 = v1;
edge->v2 = v2;
edge->weight = weight;
return edge;
exception_:
perror("Heap Allocation Error");
exit(EXIT_FAILURE);
}
示例7: throw
bool Compartment_Report_HDF5_File_Reader::load_next_frame_impl
(float * buffer) /* throw (IO_Error) */
{
// \bug No overflow check is performed
Frame_Number next_frame = (Frame_Number)_sequence_start_frame +
(Frame_Number) round(_frame_counter * _frame_skip);
// Checking if we have reached the end
bool attribute_found = false;
Frame_Number last_frame = UNDEFINED_FRAME_NUMBER; // To silent warning.
Cell_Target::iterator cell_ID = _current_cell_target.begin();
do {
H5ID file, dataset;
open_data_set(*cell_ID, "data", file, dataset);
float start_time = 0.0f,
end_time = 0.0f,
delta_time = 0.0f;
if (!read_attribute("tstart", dataset, start_time) ||
!read_attribute("tstop", dataset, end_time) ||
!read_attribute("Dt", dataset, delta_time))
{
std::string name = "a" + boost::lexical_cast<std::string>(*cell_ID);
std::string filename = (_path / (name + ".h5")).string();
throw_exception(
File_Parse_Error("Compartment_Report_HDF5_File_Reader: "
"Error reading report time attributes "
"from file:" + filename),
FATAL_LEVEL, __FILE__, __LINE__);
}
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4701 )
last_frame = (Frame_Number) round((end_time - start_time) /
delta_time) - 1;
#pragma warning ( pop )
#endif
attribute_found = true;
++cell_ID;
} while (!attribute_found && cell_ID != _current_cell_target.end());
if (!attribute_found || last_frame < next_frame)
{
// End of report reached
return false;
}
else
{
load_frames_impl(buffer, next_frame, next_frame);
_current_framestamp = next_frame;
++_frame_counter;
return true;
}
}
示例8: sr_unsubscribe
void Subscribe::unsubscribe()
{
int ret = sr_unsubscribe(_sess->_sess, _sub);
if (SR_ERR_OK != ret) {
throw_exception(ret);
}
_sub = nullptr;
}
示例9: get
type get()
{
fibers::detail::spinlock splk;
unique_lock< fibers::detail::spinlock > lk( splk);
boost::fibers::detail::scheduler::instance()->wait(lk);
if ( ! out_ec_ && ec_)
throw_exception( boost::system::system_error( ec_) );
return value_;
}
示例10: sr_event_notif_subscribe_tree
void Subscribe::event_notif_subscribe_tree(const char *xpath, S_Callback callback, void *private_ctx, sr_subscr_options_t opts)
{
callback->private_ctx["event_notif_tree"] = private_ctx;
cb_list.push_back(callback);
int ret = sr_event_notif_subscribe_tree(_sess->_sess, xpath, event_notif_tree_cb, callback->get(), opts, &_sub);
if (SR_ERR_OK != ret) {
throw_exception(ret);
}
}
示例11: sr_feature_enable_subscribe
void Subscribe::feature_enable_subscribe(S_Callback callback, void *private_ctx, sr_subscr_options_t opts)
{
callback->private_ctx["module_install"] = private_ctx;
cb_list.push_back(callback);
int ret = sr_feature_enable_subscribe(_sess->_sess, feature_enable_cb, callback->get(), opts, &_sub);
if (SR_ERR_OK != ret) {
throw_exception(ret);
}
}
示例12: throw_exception
JNIEXPORT jint JNICALL
Java_com_redhat_et_libguestfs_GuestFS__1set_1event_1callback
(JNIEnv *env, jobject obj, jlong jg, jobject jcallback, jlong jevents)
{
guestfs_h *g = (guestfs_h *) (long) jg;
int r;
struct callback_data *data;
jclass callback_class;
jmethodID method;
char key[64];
callback_class = (*env)->GetObjectClass (env, jcallback);
method = (*env)->GetMethodID (env, callback_class, METHOD_NAME, METHOD_SIGNATURE);
if (method == 0) {
throw_exception (env, "GuestFS.set_event_callback: callback class does not implement the EventCallback interface");
return -1;
}
data = malloc (sizeof *data);
if (data == NULL) {
throw_out_of_memory (env, "malloc");
return -1;
}
(*env)->GetJavaVM (env, &data->jvm);
data->method = method;
r = guestfs_set_event_callback (g, java_callback,
(uint64_t) jevents, 0, data);
if (r == -1) {
free (data);
throw_exception (env, guestfs_last_error (g));
return -1;
}
/* Register jcallback as a global reference so the GC won't free it. */
data->callback = (*env)->NewGlobalRef (env, jcallback);
/* Store 'data' in the handle, so we can free it at some point. */
snprintf (key, sizeof key, "_java_event_%d", r);
guestfs_set_private (g, key, data);
return (jint) r;
}
示例13: Java_galapi_Atomic_nativeSerialize
JNIEXPORT jstring JNICALL
Java_galapi_Atomic_nativeSerialize (JNIEnv *jne, jclass jc, jint ji) {
char *s;
galax_err err = galax_string_of_atomicValue ((atomicValue) ji, &s);
if (0 != err)
throw_exception (jne, "java/lang/RuntimeException", galax_error_string, err);
return (*jne)->NewStringUTF(jne, s);
}// Java_Atomic_nativeSerialize()
示例14: throw_galapi_exception
void
throw_galapi_exception (JNIEnv *env, char *message, int err) {
#ifdef DEBUG
fprintf(stderr,"Throwing Java exception with message: %s\n", message);
#endif
// why doesn't this work ??? :
throw_exception (env, "galapi/GalapiException", message, err);
// throw_exception (env, "java/lang/Exception", message, err);
}
示例15: gdb_rl_callback_read_char_wrapper
static void
gdb_rl_callback_read_char_wrapper (gdb_client_data client_data)
{
struct gdb_exception gdb_expt
= gdb_rl_callback_read_char_wrapper_noexcept ();
/* Rethrow using the normal EH mechanism. */
if (gdb_expt.reason < 0)
throw_exception (gdb_expt);
}