/* call-seq: db.load_extension(file) * * Loads an SQLite extension library from the named file. Extension * loading must be enabled using db.enable_load_extension(1) prior * to calling this API. */ static VALUE load_extension(VALUE self, VALUE file) { sqlite3RubyPtr ctx; int status; char *errMsg; VALUE errexp; Data_Get_Struct(self, sqlite3Ruby, ctx); REQUIRE_OPEN_DB(ctx); status = sqlite3_load_extension(ctx->db, RSTRING_PTR(file), 0, &errMsg); if (status != SQLITE_OK) { errexp = rb_exc_new2(rb_eRuntimeError, errMsg); sqlite3_free(errMsg); rb_exc_raise(errexp); } return self; }
void rugged_exception_raise(void) { VALUE err_klass, err_obj; const git_error *error; const char *err_message; error = giterr_last(); if (error && error->klass > 0 && error->klass < RUGGED_ERROR_COUNT) { err_klass = rb_eRuggedErrors[error->klass]; err_message = error->message; } else { err_klass = rb_eRuntimeError; err_message = "Rugged operation failed"; } err_obj = rb_exc_new2(err_klass, err_message); giterr_clear(); rb_exc_raise(err_obj); }
void rugged_exception_raise(void) { VALUE err_klass, err_obj; const git_error *error; const char *err_message; error = giterr_last(); if (error && error->klass >= 0 && error->klass < RUGGED_ERROR_COUNT) { err_klass = rb_eRuggedErrors[error->klass]; err_message = error->message; } else { err_klass = rb_eRuggedErrors[2]; /* InvalidError */ err_message = "Unknown Error"; } err_obj = rb_exc_new2(err_klass, err_message); giterr_clear(); rb_exc_raise(err_obj); }
VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, int cancel, const char *error, const char *source, int severity, int dberr, int oserr) { VALUE e; GET_CLIENT_USERDATA(dbproc); if (cancel && !dbdead(dbproc) && userdata && !userdata->closed) { userdata->dbsqlok_sent = 1; dbsqlok(dbproc); userdata->dbcancel_sent = 1; dbcancel(dbproc); } e = rb_exc_new2(cTinyTdsError, error); rb_funcall(e, intern_source_eql, 1, rb_str_new2(source)); if (severity) rb_funcall(e, intern_severity_eql, 1, INT2FIX(severity)); if (dberr) rb_funcall(e, intern_db_error_number_eql, 1, INT2FIX(dberr)); if (oserr) rb_funcall(e, intern_os_error_number_eql, 1, INT2FIX(oserr)); rb_exc_raise(e); return Qnil; }
static void err_append(const char *s) { rb_thread_t *th = GET_THREAD(); if (th->parse_in_eval) { if (NIL_P(th->errinfo)) { th->errinfo = rb_exc_new2(rb_eSyntaxError, s); } else { VALUE str = rb_obj_as_string(GET_THREAD()->errinfo); rb_str_cat2(str, "\n"); rb_str_cat2(str, s); th->errinfo = rb_exc_new3(rb_eSyntaxError, str); } } else { rb_write_error(s); rb_write_error("\n"); } }
static void err_append(const char *s) { extern VALUE ruby_errinfo; if (ruby_in_eval) { if (NIL_P(ruby_errinfo)) { ruby_errinfo = rb_exc_new2(rb_eSyntaxError, s); } else { VALUE str = rb_obj_as_string(ruby_errinfo); rb_str_cat2(str, "\n"); rb_str_cat2(str, s); ruby_errinfo = rb_exc_new3(rb_eSyntaxError, str); } } else { rb_write_error(s); rb_write_error("\n"); } }
VALUE do_sqlite3_cExtension_load_extension(VALUE self, VALUE path) { #ifdef HAVE_SQLITE3_ENABLE_LOAD_EXTENSION VALUE connection = rb_iv_get(self, "@connection"); if (connection == Qnil) { return Qfalse; } // Retrieve the actual connection from the object VALUE sqlite3_connection = rb_iv_get(connection, "@connection"); if (sqlite3_connection == Qnil) { return Qfalse; } sqlite3 *db; Data_Get_Struct(sqlite3_connection, sqlite3, db); const char *extension_path = rb_str_ptr_readonly(path); char *errmsg = sqlite3_malloc(1024); if (!errmsg) { return Qfalse; } int status = sqlite3_load_extension(db, extension_path, 0, &errmsg); if (status != SQLITE_OK) { VALUE errexp = rb_exc_new2(eDO_ConnectionError, errmsg); sqlite3_free(errmsg); rb_exc_raise(errexp); } sqlite3_free(errmsg); return Qtrue; #else return Qfalse; #endif }
void Init_GC(void) { VALUE rb_mObSpace; rb_mGC = rb_define_module("GC"); rb_objc_define_module_function(rb_mGC, "start", rb_gc_start, 0); rb_objc_define_module_function(rb_mGC, "enable", rb_gc_enable, 0); rb_objc_define_module_function(rb_mGC, "disable", rb_gc_disable, 0); rb_objc_define_module_function(rb_mGC, "stress", gc_stress_get, 0); rb_objc_define_module_function(rb_mGC, "stress=", gc_stress_set, 1); rb_objc_define_module_function(rb_mGC, "count", gc_count, 0); rb_objc_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0); rb_mObSpace = rb_define_module("ObjectSpace"); rb_objc_define_module_function(rb_mObSpace, "each_object", os_each_obj, -1); rb_objc_define_module_function(rb_mObSpace, "garbage_collect", rb_gc_start, 0); rb_objc_define_module_function(rb_mObSpace, "define_finalizer", define_final, -1); rb_objc_define_module_function(rb_mObSpace, "undefine_finalizer", undefine_final, 1); rb_objc_define_module_function(rb_mObSpace, "_id2ref", id2ref, 1); nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory"); GC_RETAIN(nomem_error); rb_objc_define_method(rb_mKernel, "__id__", rb_obj_id, 0); rb_objc_define_method(rb_mKernel, "object_id", rb_obj_id, 0); rb_objc_define_module_function(rb_mObSpace, "count_objects", count_objects, -1); rb_cFinalizer = rb_define_class("__Finalizer", rb_cObject); rb_objc_finalizer_finalize_super = rb_objc_install_method2((Class)rb_cFinalizer, "finalize", (IMP)rb_objc_finalizer_finalize); }
void check_constraints(asn_TYPE_descriptor_t *td, void *s) { int ret; size_t buflen = BUFSIZE; char *buffer = (char *)calloc(buflen, sizeof(char)); if (buffer == NULL) { rb_raise(rb_eException, "Can't allocate buffer to check constraints"); } ret = asn_check_constraints(td, s, buffer, &buflen); if (ret == -1) { /* Don't leak memory */ VALUE exception = rb_exc_new2(rb_eException, buffer); free(buffer); rb_exc_raise(exception); return; } free(buffer); }
static void mysql_raise(MYSQL* m) { VALUE e = rb_exc_new2(eMysql, mysql_error(m)); rb_iv_set(e, "errno", INT2FIX(mysql_errno(m))); rb_exc_raise(e); }
static VALUE magic_exception_wrapper(VALUE value) { magic_exception_t *e = (struct magic_exception *)value; return rb_exc_new2(e->klass, e->magic_error); }
void Init_Proc(void) { /* Proc */ rb_cProc = rb_define_class("Proc", rb_cObject); rb_undef_alloc_func(rb_cProc); rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, 0); rb_define_method(rb_cProc, "call", proc_call, -1); rb_define_method(rb_cProc, "[]", proc_call, -1); rb_define_method(rb_cProc, "yield", proc_yield, -1); rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0); rb_define_method(rb_cProc, "arity", proc_arity, 0); rb_define_method(rb_cProc, "clone", proc_clone, 0); rb_define_method(rb_cProc, "dup", proc_dup, 0); rb_define_method(rb_cProc, "==", proc_eq, 1); rb_define_method(rb_cProc, "eql?", proc_eq, 1); rb_define_method(rb_cProc, "hash", proc_hash, 0); rb_define_method(rb_cProc, "to_s", proc_to_s, 0); /* Exceptions */ rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError); rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0); rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0); exception_error = rb_exc_new2(rb_eFatal, "exception reentered"); rb_register_mark_object(exception_error); rb_eSysStackError = rb_define_class("SystemStackError", rb_eException); sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep"); OBJ_TAINT(sysstack_error); rb_register_mark_object(sysstack_error); /* utility functions */ rb_define_global_function("proc", rb_block_proc, 0); rb_define_global_function("lambda", proc_lambda, 0); /* Method */ rb_cMethod = rb_define_class("Method", rb_cObject); rb_undef_alloc_func(rb_cMethod); rb_undef_method(CLASS_OF(rb_cMethod), "new"); rb_define_method(rb_cMethod, "==", method_eq, 1); rb_define_method(rb_cMethod, "eql?", method_eq, 1); rb_define_method(rb_cMethod, "hash", method_hash, 0); rb_define_method(rb_cMethod, "clone", method_clone, 0); rb_define_method(rb_cMethod, "call", rb_method_call, -1); rb_define_method(rb_cMethod, "[]", rb_method_call, -1); rb_define_method(rb_cMethod, "arity", method_arity_m, 0); rb_define_method(rb_cMethod, "inspect", method_inspect, 0); rb_define_method(rb_cMethod, "to_s", method_inspect, 0); rb_define_method(rb_cMethod, "to_proc", method_proc, 0); rb_define_method(rb_cMethod, "receiver", method_receiver, 0); rb_define_method(rb_cMethod, "name", method_name, 0); rb_define_method(rb_cMethod, "owner", method_owner, 0); rb_define_method(rb_cMethod, "unbind", method_unbind, 0); rb_define_method(rb_mKernel, "method", rb_obj_method, 1); /* UnboundMethod */ rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject); rb_undef_alloc_func(rb_cUnboundMethod); rb_undef_method(CLASS_OF(rb_cUnboundMethod), "new"); rb_define_method(rb_cUnboundMethod, "==", method_eq, 1); rb_define_method(rb_cUnboundMethod, "eql?", method_eq, 1); rb_define_method(rb_cUnboundMethod, "hash", method_hash, 0); rb_define_method(rb_cUnboundMethod, "clone", method_clone, 0); rb_define_method(rb_cUnboundMethod, "arity", method_arity_m, 0); rb_define_method(rb_cUnboundMethod, "inspect", method_inspect, 0); rb_define_method(rb_cUnboundMethod, "to_s", method_inspect, 0); rb_define_method(rb_cUnboundMethod, "name", method_name, 0); rb_define_method(rb_cUnboundMethod, "owner", method_owner, 0); rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1); /* Module#*_method */ rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1); rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1); }
void do_throw(Error& error) { rb_exc_raise(rb_exc_new2(exception_klass(error), error.buf)); }
VALUE buildException(char * message) { VALUE errclass = rb_eval_string("HaskellError"); VALUE errobj = rb_exc_new2(errclass, message); return errobj; // return rb_funcall(errclass, rb_intern("new"), 1, rb_str_new2(message)); }
/* * call-seq: * Commit.create(repository, data = {}) -> oid * * Write a new +Commit+ object to +repository+, with the given +data+ * arguments, passed as a +Hash+: * * - +:message+: a string with the full text for the commit's message * - +:committer+ (optional): a hash with the signature for the committer, * defaults to the signature from the configuration * - +:author+ (optional): a hash with the signature for the author, * defaults to the signature from the configuration * - +:parents+: an +Array+ with zero or more parents for this commit, * represented as <tt>Rugged::Commit</tt> instances, or OID +String+. * - +:tree+: the tree for this commit, represented as a <tt>Rugged::Tree</tt> * instance or an OID +String+. * - +:update_ref+ (optional): a +String+ with the name of a reference in the * repository which should be updated to point to this commit (e.g. "HEAD") * * When the commit is successfully written to disk, its +oid+ will be * returned as a hex +String+. * * author = {:email=>"*****@*****.**", :time=>Time.now, :name=>"Vicent Mart\303\255"} * * Rugged::Commit.create(r, * :author => author, * :message => "Hello world\n\n", * :committer => author, * :parents => ["2cb831a8aea28b2c1b9c63385585b864e4d3bad1"], * :tree => some_tree) #=> "f148106ca58764adc93ad4e2d6b1d168422b9796" */ static VALUE rb_git_commit_create(VALUE self, VALUE rb_repo, VALUE rb_data) { VALUE rb_message, rb_tree, rb_parents, rb_ref; VALUE rb_err_obj = Qnil; int parent_count, i, error = 0; const git_commit **parents = NULL; git_commit **free_list = NULL; git_tree *tree; git_signature *author, *committer; git_oid commit_oid; git_repository *repo; const char *update_ref = NULL; Check_Type(rb_data, T_HASH); rugged_check_repo(rb_repo); Data_Get_Struct(rb_repo, git_repository, repo); rb_ref = rb_hash_aref(rb_data, CSTR2SYM("update_ref")); if (!NIL_P(rb_ref)) { Check_Type(rb_ref, T_STRING); update_ref = StringValueCStr(rb_ref); } rb_message = rb_hash_aref(rb_data, CSTR2SYM("message")); Check_Type(rb_message, T_STRING); committer = rugged_signature_get( rb_hash_aref(rb_data, CSTR2SYM("committer")), repo ); author = rugged_signature_get( rb_hash_aref(rb_data, CSTR2SYM("author")), repo ); rb_parents = rb_hash_aref(rb_data, CSTR2SYM("parents")); Check_Type(rb_parents, T_ARRAY); rb_tree = rb_hash_aref(rb_data, CSTR2SYM("tree")); tree = (git_tree *)rugged_object_get(repo, rb_tree, GIT_OBJ_TREE); parents = alloca(RARRAY_LEN(rb_parents) * sizeof(void *)); free_list = alloca(RARRAY_LEN(rb_parents) * sizeof(void *)); parent_count = 0; for (i = 0; i < (int)RARRAY_LEN(rb_parents); ++i) { VALUE p = rb_ary_entry(rb_parents, i); git_commit *parent = NULL; git_commit *free_ptr = NULL; if (NIL_P(p)) continue; if (TYPE(p) == T_STRING) { git_oid oid; error = git_oid_fromstr(&oid, StringValueCStr(p)); if (error < GIT_OK) goto cleanup; error = git_commit_lookup(&parent, repo, &oid); if (error < GIT_OK) goto cleanup; free_ptr = parent; } else if (rb_obj_is_kind_of(p, rb_cRuggedCommit)) { Data_Get_Struct(p, git_commit, parent); } else { rb_err_obj = rb_exc_new2(rb_eTypeError, "Invalid type for parent object"); goto cleanup; } parents[parent_count] = parent; free_list[parent_count] = free_ptr; parent_count++; } error = git_commit_create( &commit_oid, repo, update_ref, author, committer, NULL, StringValueCStr(rb_message), tree, parent_count, parents); cleanup: git_signature_free(author); git_signature_free(committer); git_object_free((git_object *)tree); for (i = 0; i < parent_count; ++i) git_object_free((git_object *)free_list[i]); if (!NIL_P(rb_err_obj)) rb_exc_raise(rb_err_obj); rugged_exception_check(error); return rugged_create_oid(&commit_oid); }
static void rldap_raise(int errno) { VALUE e = rb_exc_new2(eLDAP, ldap_err2string(errno)); rb_iv_set(e, "@errno", INT2FIX(errno)); rb_exc_raise(e); }
static VALUE ruby_libvirt_exc_new2_wrap(VALUE arg) { struct rb_exc_new2_arg *e = (struct rb_exc_new2_arg *)arg; return rb_exc_new2(e->error, e->msg); }
VALUE exception_spec_rb_exc_new2(VALUE self, VALUE str) { char *cstr = StringValuePtr(str); return rb_exc_new2(rb_eException, cstr); }
/** * Parse the commit options into something we can re-use * * Note that parents may be set even when the function errors, so make * sure to free this data. */ static VALUE parse_commit_options(struct commit_data *out, git_repository *repo, VALUE rb_data) { VALUE rb_message, rb_tree, rb_parents, rb_ref; int error = 0, parent_count, i; rb_ref = rb_hash_aref(rb_data, CSTR2SYM("update_ref")); if (!NIL_P(rb_ref)) { Check_Type(rb_ref, T_STRING); out->update_ref = StringValueCStr(rb_ref); } rb_message = rb_hash_aref(rb_data, CSTR2SYM("message")); Check_Type(rb_message, T_STRING); out->message = StringValueCStr(rb_message); out->committer = rugged_signature_get( rb_hash_aref(rb_data, CSTR2SYM("committer")), repo ); out->author = rugged_signature_get( rb_hash_aref(rb_data, CSTR2SYM("author")), repo ); rb_parents = rb_hash_aref(rb_data, CSTR2SYM("parents")); Check_Type(rb_parents, T_ARRAY); rb_tree = rb_hash_aref(rb_data, CSTR2SYM("tree")); out->tree = (git_tree *)rugged_object_get(repo, rb_tree, GIT_OBJ_TREE); out->parents = xcalloc(RARRAY_LEN(rb_parents), sizeof(void *)); parent_count = 0; for (i = 0; i < (int)RARRAY_LEN(rb_parents); ++i) { VALUE p = rb_ary_entry(rb_parents, i); git_commit *parent = NULL; git_commit *tmp = NULL; if (NIL_P(p)) continue; if (TYPE(p) == T_STRING) { git_oid oid; error = git_oid_fromstr(&oid, StringValueCStr(p)); if (error < GIT_OK) goto out; error = git_commit_lookup(&parent, repo, &oid); if (error < GIT_OK) goto out; } else if (rb_obj_is_kind_of(p, rb_cRuggedCommit)) { Data_Get_Struct(p, git_commit, tmp); if ((error = git_object_dup((git_object **) &parent, (git_object *) tmp)) < 0) goto out; } else { out->rb_err_obj = rb_exc_new2(rb_eTypeError, "Invalid type for parent object"); error = -1; goto out; } out->parents[parent_count] = parent; parent_count++; } out: out->parent_count = parent_count; return error; }
static void *read_blob(FILE *input, size_t length, size_t *raw_length) { VALUE exc = Qnil; void *buffer = NULL; OSMPBF__Blob *blob = NULL; if(length < 1 || length > MAX_BLOB_SIZE) rb_raise(rb_eIOError, "Invalid blob size"); if(!(buffer = malloc(length))) rb_raise(rb_eNoMemError, "Unable to allocate memory for the blob"); if(fread(buffer, length, 1, input)) blob = osmpbf__blob__unpack(NULL, length, buffer); free(buffer); if(blob == NULL) rb_raise(rb_eIOError, "Unable to read the blob"); void *data = NULL; if(blob->has_raw) { if(!(data = malloc(blob->raw.len))) { exc = rb_exc_new2(rb_eNoMemError, "Unable to allocate memory for the data"); goto exit_nicely; } memcpy(data, blob->raw.data, blob->raw.len); *raw_length = blob->raw.len; } else if(blob->has_zlib_data) { if(!(data = malloc(MAX_BLOB_SIZE))) { exc = rb_exc_new2(rb_eNoMemError, "Unable to allocate memory for the data"); goto exit_nicely; } int ret; z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = (unsigned int)blob->zlib_data.len; strm.next_in = blob->zlib_data.data; strm.avail_out = blob->raw_size; strm.next_out = data; ret = inflateInit(&strm); if (ret != Z_OK) { exc = rb_exc_new2(rb_eRuntimeError, "Zlib init failed"); goto exit_nicely; } ret = inflate(&strm, Z_NO_FLUSH); (void)inflateEnd(&strm); if (ret != Z_STREAM_END) { exc = rb_exc_new2(rb_eRuntimeError, "Zlib compression failed"); goto exit_nicely; } *raw_length = blob->raw_size; } else if(blob->has_lzma_data) { exc = rb_exc_new2(rb_eNotImpError, "LZMA compression is not supported"); goto exit_nicely; } else { exc = rb_exc_new2(rb_eNotImpError, "Unknown blob format"); goto exit_nicely; } exit_nicely: if(blob) osmpbf__blob__free_unpacked(blob, NULL); if(!data) free(data); if(exc != Qnil) rb_exc_raise(exc); return data; }
/* * call-seq: * remote.push(refspecs = nil, options = {}) -> hash * * Pushes the given +refspecs+ to the given +remote+. Returns a hash that contains * key-value pairs that reflect pushed refs and error messages, if applicable. * * The following options can be passed in the +options+ Hash: * * :credentials :: * The credentials to use for the push operation. Can be either an instance of one * of the Rugged::Credentials types, or a proc returning one of the former. * The proc will be called with the +url+, the +username+ from the url (if applicable) and * a list of applicable credential types. * * :message :: * A single line log message to be appended to the reflog of each local remote-tracking * branch that gets updated. Defaults to: "fetch". * * :signature :: * The signature to be used for populating the reflog entries. * * Example: * * remote = Rugged::Remote.lookup(@repo, 'origin') * remote.push(["refs/heads/master", ":refs/heads/to_be_deleted"]) */ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self) { VALUE rb_refspecs, rb_options, rb_val; VALUE rb_repo = rugged_owner(self); VALUE rb_exception = Qnil, rb_result = rb_hash_new(); git_repository *repo; git_remote *remote, *tmp_remote = NULL; git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT; git_push *push = NULL; git_signature *signature = NULL; int error = 0, i = 0; char *log_message = NULL; struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, 0 }; rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options); if (!NIL_P(rb_refspecs)) { Check_Type(rb_refspecs, T_ARRAY); for (i = 0; i < RARRAY_LEN(rb_refspecs); ++i) { VALUE rb_refspec = rb_ary_entry(rb_refspecs, i); Check_Type(rb_refspec, T_STRING); } } rugged_check_repo(rb_repo); Data_Get_Struct(rb_repo, git_repository, repo); Data_Get_Struct(self, git_remote, remote); if (!NIL_P(rb_options)) { rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload); rb_val = rb_hash_aref(rb_options, CSTR2SYM("message")); if (!NIL_P(rb_val)) log_message = StringValueCStr(rb_val); rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature")); if (!NIL_P(rb_val)) signature = rugged_signature_get(rb_val, repo); } // Create a temporary remote that we use for pushing if ((error = git_remote_dup(&tmp_remote, remote)) || (error = git_remote_set_callbacks(tmp_remote, &callbacks))) goto cleanup; if (!NIL_P(rb_refspecs)) { git_remote_clear_refspecs(tmp_remote); for (i = 0; !error && i < RARRAY_LEN(rb_refspecs); ++i) { VALUE rb_refspec = rb_ary_entry(rb_refspecs, i); if ((error = git_remote_add_push(tmp_remote, StringValueCStr(rb_refspec)))) goto cleanup; } } if ((error = git_push_new(&push, tmp_remote))) goto cleanup; // TODO: Get rid of this once git_remote_push lands in libgit2. { git_strarray push_refspecs; size_t i; if ((error = git_remote_get_push_refspecs(&push_refspecs, tmp_remote))) goto cleanup; if (push_refspecs.count == 0) { rb_exception = rb_exc_new2(rb_eRuggedError, "no pushspecs are configured for the given remote"); goto cleanup; } for (i = 0; !error && i < push_refspecs.count; ++i) { error = git_push_add_refspec(push, push_refspecs.strings[i]); } git_strarray_free(&push_refspecs); if (error) goto cleanup; } if ((error = git_push_finish(push))) goto cleanup; if (!git_push_unpack_ok(push)) { rb_exception = rb_exc_new2(rb_eRuggedError, "the remote side did not unpack successfully"); goto cleanup; } if ((error = git_push_status_foreach(push, &push_status_cb, (void *)rb_result)) || (error = git_push_update_tips(push, signature, log_message))) goto cleanup; cleanup: git_push_free(push); git_remote_free(tmp_remote); git_signature_free(signature); if (!NIL_P(rb_exception)) rb_exc_raise(rb_exception); rugged_exception_check(error); return rb_result; }
void rb_sqlite3_raise(sqlite3 * db, int status) { VALUE klass = Qnil; /* Consider only lower 8 bits, to work correctly when extended result codes are enabled. */ switch(status & 0xff) { case SQLITE_OK: return; break; case SQLITE_ERROR: klass = rb_path2class("SQLite3::SQLException"); break; case SQLITE_INTERNAL: klass = rb_path2class("SQLite3::InternalException"); break; case SQLITE_PERM: klass = rb_path2class("SQLite3::PermissionException"); break; case SQLITE_ABORT: klass = rb_path2class("SQLite3::AbortException"); break; case SQLITE_BUSY: klass = rb_path2class("SQLite3::BusyException"); break; case SQLITE_LOCKED: klass = rb_path2class("SQLite3::LockedException"); break; case SQLITE_NOMEM: klass = rb_path2class("SQLite3::MemoryException"); break; case SQLITE_READONLY: klass = rb_path2class("SQLite3::ReadOnlyException"); break; case SQLITE_INTERRUPT: klass = rb_path2class("SQLite3::InterruptException"); break; case SQLITE_IOERR: klass = rb_path2class("SQLite3::IOException"); break; case SQLITE_CORRUPT: klass = rb_path2class("SQLite3::CorruptException"); break; case SQLITE_NOTFOUND: klass = rb_path2class("SQLite3::NotFoundException"); break; case SQLITE_FULL: klass = rb_path2class("SQLite3::FullException"); break; case SQLITE_CANTOPEN: klass = rb_path2class("SQLite3::CantOpenException"); break; case SQLITE_PROTOCOL: klass = rb_path2class("SQLite3::ProtocolException"); break; case SQLITE_EMPTY: klass = rb_path2class("SQLite3::EmptyException"); break; case SQLITE_SCHEMA: klass = rb_path2class("SQLite3::SchemaChangedException"); break; case SQLITE_TOOBIG: klass = rb_path2class("SQLite3::TooBigException"); break; case SQLITE_CONSTRAINT: klass = rb_path2class("SQLite3::ConstraintException"); break; case SQLITE_MISMATCH: klass = rb_path2class("SQLite3::MismatchException"); break; case SQLITE_MISUSE: klass = rb_path2class("SQLite3::MisuseException"); break; case SQLITE_NOLFS: klass = rb_path2class("SQLite3::UnsupportedException"); break; case SQLITE_AUTH: klass = rb_path2class("SQLite3::AuthorizationException"); break; case SQLITE_FORMAT: klass = rb_path2class("SQLite3::FormatException"); break; case SQLITE_RANGE: klass = rb_path2class("SQLite3::RangeException"); break; case SQLITE_NOTADB: klass = rb_path2class("SQLite3::NotADatabaseException"); break; default: klass = rb_eRuntimeError; } klass = rb_exc_new2(klass, sqlite3_errmsg(db)); rb_iv_set(klass, "@code", INT2FIX(status)); rb_exc_raise(klass); }