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); } }
/* 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); }
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__); } }
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; }
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>(); }
/* 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); }
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; } }
void Subscribe::unsubscribe() { int ret = sr_unsubscribe(_sess->_sess, _sub); if (SR_ERR_OK != ret) { throw_exception(ret); } _sub = nullptr; }
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_; }
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); } }
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); } }
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; }
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()
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); }
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); }
BENCHMARK_RELATIVE(exception_wrapper_create_and_throw, iters) { std::runtime_error e("payload"); for (size_t i = 0; i < iters; ++i) { auto ew = folly::make_exception_wrapper<std::runtime_error>(e); try { ew.throw_exception(); } catch (std::runtime_error&) { } } }
int testSimObject::call_function( Trick::JobData * curr_job ) { int trick_ret = 0 ; switch (curr_job->id) { case 0: trick_ret = default_data_1() ; break ; case 1: trick_ret = input_processor_1() ; break ; case 2: trick_ret = initialization_1() ; break ; case 3: trick_ret = top_of_frame_1() ; break ; case 4: case 5: case 6: case 7: case 8: trick_ret = scheduled_1() ; break ; case 9: trick_ret = end_of_frame_1() ; break ; case 10: trick_ret = shutdown_1() ; break ; case 11: trick_ret = freeze_init_1() ; break ; case 12: trick_ret = freeze_1() ; break ; case 13: trick_ret = freeze_scheduled_1() ; break ; case 14: trick_ret = unfreeze_1() ; break ; case 15: trick_ret = time_tic_changed_1() ; break ; case 101: trick_ret = return_error() ; break ; case 102: trick_ret = throw_exception() ; break ; default: trick_ret = -1 ; break ; } return trick_ret ; } ;
void Subscribe::subtree_change_subscribe(const char *xpath, S_Callback callback, void *private_ctx, \ uint32_t priority, sr_subscr_options_t opts) { callback->private_ctx["subtree_change"] = private_ctx; cb_list.push_back(callback); int ret = sr_subtree_change_subscribe(_sess->_sess, xpath, subtree_change_cb, callback->get(), priority, opts, &_sub); if (SR_ERR_OK != ret) { throw_exception(ret); } }
// update_decl = "update" "(" identifier "," dictionary ")". bool adam_test_parser::is_update_decl() { if (is_keyword(update_k)) { require_token(open_parenthesis_k); name_t name; if (!is_identifier(name)) throw_exception("sheet name expected"); queryable_sheet_t& qs(sheet_from_name(name)); require_token(comma_k); array_t expression; if (!is_dictionary(expression)) throw_exception("dictionary expected"); require_token(close_parenthesis_k); any_regular_t dict(qs.inspect(expression)); dictionary_t d(dict.cast<adobe::dictionary_t>()); qs.set(d); qs.update(); return true; } return false; }
/* SRC: classes/directoryiterator.php line 14 */ void c_DirectoryIterator::t___construct(Variant v_path) { INSTANCE_METHOD_INJECTION_BUILTIN(DirectoryIterator, DirectoryIterator::__construct); if (!(x_hphp_directoryiterator___construct(GET_THIS_TYPED(DirectoryIterator), toString(v_path)))) { { { p_UnexpectedValueException tmp0 = coo_UnexpectedValueException(); throw_exception(((c_UnexpectedValueException*)tmp0.get()->create(concat3(NAMSTR(s_sys_ss19fa93f0, "DirectoryIterator::__construct("), toString(v_path), NAMSTR(s_sys_ss4e2ff123, "): failed to open dir"))), tmp0)); } } } }
// print_decl = "print" "(" identifier "," expression ")". bool adam_test_parser::is_print_decl() { if (is_keyword(print_k)) { require_token(open_parenthesis_k); name_t name; if (!is_identifier(name)) throw_exception("sheet name expected"); queryable_sheet_t& qs(sheet_from_name(name)); require_token(comma_k); array_t expression; if (!is_expression(expression)) throw_exception("expression expected"); require_token(close_parenthesis_k); any_regular_t result = qs.inspect(expression); #if defined(ADOBE_STD_SERIALIZATION) out_m << begin_asl_cel << expression << end_asl_cel << std::endl; #endif return true; } return false; }
int catch_exceptions_with_msg (struct ui_out *func_uiout, catch_exceptions_ftype *func, void *func_args, char **gdberrmsg, return_mask mask) { struct gdb_exception exception = exception_none; volatile int val = 0; struct ui_out *saved_uiout; /* Save and override the global ``struct ui_out'' builder. */ saved_uiout = current_uiout; current_uiout = func_uiout; TRY { val = (*func) (current_uiout, func_args); } CATCH (ex, RETURN_MASK_ALL) { exception = ex; } END_CATCH /* Restore the global builder. */ current_uiout = saved_uiout; if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0) { /* The caller didn't request that the event be caught. Rethrow. */ throw_exception (exception); } exception_print (gdb_stderr, exception); gdb_assert (val >= 0); gdb_assert (exception.reason <= 0); if (exception.reason < 0) { /* If caller wants a copy of the low-level error message, make one. This is used in the case of a silent error whereby the caller may optionally want to issue the message. */ if (gdberrmsg != NULL) { if (exception.message != NULL) *gdberrmsg = xstrdup (exception.message); else *gdberrmsg = NULL; } return exception.reason; } return val; }
int enduse_init(enduse *e) { #ifdef _DEBUG if (e->magic!=enduse_magic) throw_exception("enduse '%s' magic number bad", e->name); #endif e->t_last = TS_ZERO; return 0; }
void test_i::unknown_exception_in_method (void) { ACE_DEBUG ((LM_DEBUG, "test_i::unknown_exception_in_method() called\n")); ACE_DEBUG ((LM_DEBUG, "Unknown exception being generated: should be propagated to the client\n")); throw_exception (); }
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_nio_ByteBuffer_2II (JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen) { char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed); if(compressedBuffer == 0) { throw_exception(env, self, 3); return (jint) 0; } bool ret = snappy::IsValidCompressedBuffer(compressedBuffer + cpos, (size_t) clen); return ret; }
void Subscribe::dp_get_items_subscribe(const char *xpath, S_Callback callback, void *private_ctx,\ sr_subscr_options_t opts) { callback->private_ctx["dp_get_items"] = private_ctx; cb_list.push_back(callback); int ret = sr_dp_get_items_subscribe(_sess->_sess, xpath, dp_get_items_cb, callback->get(), opts, &_sub); if (SR_ERR_OK != ret) { throw_exception(ret); } }
/* * Class: org_xerial_snappy_Snappy * Method: uncompress * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)Z */ JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__Ljava_nio_ByteBuffer_2IILjava_nio_ByteBuffer_2I (JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen, jobject decompressed, jint dpos) { char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed); char* decompressedBuffer = (char*) env->GetDirectBufferAddress(decompressed); if(compressedBuffer == 0 || decompressedBuffer == 0) { throw_exception(env, self, 3); return (jint) 0; } size_t decompressedLength; snappy::GetUncompressedLength(compressedBuffer + cpos, (size_t) clen, &decompressedLength); bool ret = snappy::RawUncompress(compressedBuffer + cpos, (size_t) clen, decompressedBuffer + dpos); if(!ret) { throw_exception(env, self, 5); return 0; } return (jint) decompressedLength; }
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_lang_Object_2II (JNIEnv * env, jobject self, jobject input, jint offset, jint length) { char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0); if(in == 0) { // out of memory throw_exception(env, self, 4); return 0; } size_t result; bool ret = snappy::GetUncompressedLength(in + offset, (size_t) length, &result); env->ReleasePrimitiveArrayCritical((jarray) input, in, 0); if(!ret) { throw_exception(env, self, 2); return 0; } return (jint) result; }
void throw_exception_( E const & x, char const * current_function, char const * file, int line ) { throw_exception( set_info( set_info( set_info( enable_error_info(x), throw_function(current_function)), throw_file(file)), throw_line(line))); }
int jba_to_bigint(JNIEnv *env, BIGNUM **out, jbyteArray jba) { jsize len; len = (*env)->GetArrayLength(env, jba); if (!len) { throw_exception(env, "java/lang/RuntimeException", "Could not convert BIGNUM"); return (0); } // LOGD("BigInt Size is: %d\n", len); jbyte buff[len]; (*env)->GetByteArrayRegion(env, jba, 0, len, buff); *out = BN_bin2bn(buff, len, NULL); if (*out == NULL) { throw_exception(env, "java/lang/RuntimeException", "Could not convert BIGNUM"); return (0); } return (1); }