本文整理汇总了C++中rb_exc_raise函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_exc_raise函数的具体用法?C++ rb_exc_raise怎么用?C++ rb_exc_raise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_exc_raise函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rb_grn_context_check
void
rb_grn_context_check (grn_ctx *context, VALUE related_object)
{
VALUE exception;
exception = rb_grn_context_to_exception(context, related_object);
if (NIL_P(exception))
return;
rb_exc_raise(exception);
}
开发者ID:nobu,项目名称:rroonga,代码行数:11,代码来源:rb-grn-context.c
示例2: rb_loaderror
void
rb_loaderror(const char *fmt, ...)
{
va_list args;
char buf[BUFSIZ];
va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new2(rb_eLoadError, buf));
}
开发者ID:tflynn,项目名称:ruby19-norubygems,代码行数:11,代码来源:error.c
示例3: LocalMemCache__each_pair
/*
* call-seq:
* lmc.each_pair {|k, v| block } -> nil
*
* Iterates over hashtable.
*/
static VALUE LocalMemCache__each_pair(VALUE obj) {
VALUE d = rb_ary_new();
rb_ary_push(d, obj);
int error = 0;
rb_protect(__LocalMemCache__each_pair, d, &error);
if (error) {
lmc_unlock_shm_region("local_memcache_iterate", get_LocalMemCache(obj));
rb_exc_raise(ruby_errinfo);
}
return Qnil;
}
开发者ID:dkhenry,项目名称:localmemcache,代码行数:17,代码来源:rblocalmemcache.c
示例4: rb_raise
void
rb_raise(VALUE exc, const char *fmt, ...)
{
va_list args;
VALUE mesg;
va_start(args, fmt);
mesg = rb_vsprintf(fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new3(exc, mesg));
}
开发者ID:evan,项目名称:ruby,代码行数:11,代码来源:error.c
示例5: rb_raise
void
rb_raise(VALUE exc, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZ];
va_start(args,fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new2(exc, buf));
}
开发者ID:tflynn,项目名称:ruby19-norubygems,代码行数:11,代码来源:error.c
示例6: sedna_err
// Test the last error message for conn, and raise an exception if there is one.
// The type of the exception is based on the result of the function that was
// called that generated the error and should be passed as res.
static void sedna_err(SC *conn, int res)
{
VALUE exc_class, exc;
const char *msg;
char *code, *err, *details, *p, exc_message[BUFSIZ];
switch(res) {
case SEDNA_AUTHENTICATION_FAILED:
exc_class = cSednaAuthError; break;
case SEDNA_OPEN_SESSION_FAILED:
case SEDNA_CLOSE_SESSION_FAILED:
exc_class = cSednaConnError; break;
case SEDNA_BEGIN_TRANSACTION_FAILED:
case SEDNA_ROLLBACK_TRANSACTION_FAILED:
case SEDNA_COMMIT_TRANSACTION_FAILED:
exc_class = cSednaTrnError; break;
case SEDNA_ERROR:
default:
exc_class = cSednaException;
}
msg = SEgetLastErrorMsg(conn);
// SEgetLastErrorCode(conn) is useless, because it varies if the order of
// errors changes. The actual code is a string which is defined in error_codes.h
// in the Sedna source code.
code = strstr(msg, "ERROR ");
err = strstr(msg, "\n");
details = strstr(err, "\nDetails: ");
if(code != NULL) {
code += 6; // Advance beyond "ERROR "
if((p = strstr(code, "\n")) != NULL) strncpy(p, "\0", 1);
}
if(err != NULL) {
err++; // Advance beyond "\n"
if((p = strstr(err, "\n")) != NULL) strncpy(p, "\0", 1);
} else {
err = strdup("Unknown error.");
}
if(details != NULL) {
details += 10; // Advance beyond "\nDetails: "
while((p = strstr(details, "\n")) != NULL) strncpy(p, " ", 1);
snprintf(exc_message, BUFSIZ, "%s (%s)", err, details);
} else {
snprintf(exc_message, BUFSIZ, "%s", err);
}
exc = rb_exc_new2(exc_class, exc_message);
if(code != NULL) {
rb_iv_set(exc, IV_EXC_CODE, rb_str_new2(code));
}
rb_exc_raise(exc);
}
开发者ID:rolftimmermans,项目名称:sedna-ruby,代码行数:57,代码来源:sedna.c
示例7: pg_result_check
/*
* call-seq:
* res.check -> nil
*
* Raises appropriate exception if PG::Result is in a bad state.
*/
VALUE
pg_result_check( VALUE self )
{
VALUE error, exception;
VALUE rb_pgconn = rb_iv_get( self, "@connection" );
PGconn *conn = pg_get_pgconn(rb_pgconn);
PGresult *result;
#ifdef M17N_SUPPORTED
rb_encoding *enc = pg_conn_enc_get( conn );
#endif
Data_Get_Struct(self, PGresult, result);
if(result == NULL)
{
error = rb_str_new2( PQerrorMessage(conn) );
}
else
{
switch (PQresultStatus(result))
{
case PGRES_TUPLES_OK:
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
#ifdef HAVE_CONST_PGRES_COPY_BOTH
case PGRES_COPY_BOTH:
#endif
#ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
case PGRES_SINGLE_TUPLE:
#endif
case PGRES_EMPTY_QUERY:
case PGRES_COMMAND_OK:
return Qnil;
case PGRES_BAD_RESPONSE:
case PGRES_FATAL_ERROR:
case PGRES_NONFATAL_ERROR:
error = rb_str_new2( PQresultErrorMessage(result) );
break;
default:
error = rb_str_new2( "internal error : unknown result status." );
}
}
#ifdef M17N_SUPPORTED
rb_enc_set_index( error, rb_enc_to_index(enc) );
#endif
exception = rb_exc_new3( rb_ePGerror, error );
rb_iv_set( exception, "@connection", rb_pgconn );
rb_iv_set( exception, "@result", self );
rb_exc_raise( exception );
/* Not reached */
return Qnil;
}
开发者ID:danielcode,项目名称:ruby-pg,代码行数:60,代码来源:pg_result.c
示例8: transform
/*
* call-seq:
* transform(document, params = [])
*
* Apply an XSLT stylesheet to an XML::Document.
* +params+ is an array of strings used as XSLT parameters.
* returns Nokogiri::XML::Document
*
* Example:
*
* doc = Nokogiri::XML(File.read(ARGV[0]))
* xslt = Nokogiri::XSLT(File.read(ARGV[1]))
* puts xslt.transform(doc, ['key', 'value'])
*
*/
static VALUE transform(int argc, VALUE* argv, VALUE self)
{
VALUE xmldoc, paramobj, errstr, exception ;
xmlDocPtr xml ;
xmlDocPtr result ;
nokogiriXsltStylesheetTuple *wrapper;
const char** params ;
long param_len, j ;
int parse_error_occurred ;
rb_scan_args(argc, argv, "11", &xmldoc, ¶mobj);
if (NIL_P(paramobj)) { paramobj = rb_ary_new2(0L) ; }
if (!rb_obj_is_kind_of(xmldoc, cNokogiriXmlDocument))
rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::Document");
/* handle hashes as arguments. */
if(T_HASH == TYPE(paramobj)) {
paramobj = rb_funcall(paramobj, rb_intern("to_a"), 0);
paramobj = rb_funcall(paramobj, rb_intern("flatten"), 0);
}
Check_Type(paramobj, T_ARRAY);
Data_Get_Struct(xmldoc, xmlDoc, xml);
Data_Get_Struct(self, nokogiriXsltStylesheetTuple, wrapper);
param_len = RARRAY_LEN(paramobj);
params = calloc((size_t)param_len+1, sizeof(char*));
for (j = 0 ; j < param_len ; j++) {
VALUE entry = rb_ary_entry(paramobj, j);
const char * ptr = StringValuePtr(entry);
params[j] = ptr;
}
params[param_len] = 0 ;
errstr = rb_str_new(0, 0);
xsltSetGenericErrorFunc((void *)errstr, xslt_generic_error_handler);
xmlSetGenericErrorFunc(NULL, (xmlGenericErrorFunc)&swallow_superfluous_xml_errors);
result = xsltApplyStylesheet(wrapper->ss, xml, params);
free(params);
xsltSetGenericErrorFunc(NULL, NULL);
xmlSetGenericErrorFunc(NULL, NULL);
parse_error_occurred = (Qfalse == rb_funcall(errstr, rb_intern("empty?"), 0));
if (parse_error_occurred) {
exception = rb_exc_new3(rb_eRuntimeError, errstr);
rb_exc_raise(exception);
}
return Nokogiri_wrap_xml_document((VALUE)0, result) ;
}
开发者ID:00zl00,项目名称:AlfredWorkflow.com,代码行数:69,代码来源:xslt_stylesheet.c
示例9: vm_push_frame
static inline rb_control_frame_t *
vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq,
VALUE type, VALUE self, VALUE specval,
const VALUE *pc, VALUE *sp, VALUE *lfp,
int local_size)
{
rb_control_frame_t * const cfp = th->cfp - 1;
int i;
if ((void *)(sp + local_size) >= (void *)cfp) {
rb_exc_raise(sysstack_error);
}
th->cfp = cfp;
/* setup vm value stack */
/* nil initialize */
for (i=0; i < local_size; i++) {
*sp = Qnil;
sp++;
}
/* set special val */
*sp = GC_GUARDED_PTR(specval);
if (lfp == 0) {
lfp = sp;
}
/* setup vm control frame stack */
cfp->pc = (VALUE *)pc;
cfp->sp = sp + 1;
cfp->bp = sp + 1;
cfp->iseq = (rb_iseq_t *) iseq;
cfp->flag = type;
cfp->self = self;
cfp->lfp = lfp;
cfp->dfp = sp;
cfp->block_iseq = 0;
cfp->proc = 0;
cfp->me = 0;
#define COLLECT_PROFILE 0
#if COLLECT_PROFILE
cfp->prof_time_self = clock();
cfp->prof_time_chld = 0;
#endif
if (VMDEBUG == 2) {
SDR();
}
return cfp;
}
开发者ID:217,项目名称:ruby,代码行数:54,代码来源:vm_insnhelper.c
示例10: rb_loaderror
void
rb_loaderror(const char *fmt, ...)
{
va_list args;
VALUE mesg;
va_start(args, fmt);
mesg = rb_enc_vsprintf(rb_locale_encoding(), fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new3(rb_eLoadError, mesg));
}
开发者ID:evan,项目名称:ruby,代码行数:11,代码来源:error.c
示例11: startTransactionRescue
VALUE startTransactionRescue(VALUE transaction, VALUE error)
{
rb_funcall(transaction, rb_intern("rollback"), 0);
rb_exc_raise(error);
return(Qnil);
}
开发者ID:wndxlori,项目名称:ibruby,代码行数:11,代码来源:Connection.c
示例12: executeImmediateRescue
VALUE executeImmediateRescue(VALUE set, VALUE error)
{
rb_funcall(set, rb_intern("close"), 0);
rb_exc_raise(error);
return(Qnil);
}
开发者ID:wndxlori,项目名称:ibruby,代码行数:11,代码来源:Connection.c
示例13: rb_memerror
void
rb_memerror()
{
static int recurse = 0;
if (!nomem_error || (recurse > 0 && rb_safe_level() < 4)) {
fprintf(stderr, "[FATAL] failed to allocate memory\n");
exit(1);
}
recurse++;
rb_exc_raise(nomem_error);
}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:12,代码来源:gc.c
示例14: libssh_ruby_raise
void libssh_ruby_raise(ssh_session session) {
VALUE exc, code, message;
VALUE argv[1];
code = INT2FIX(ssh_get_error_code(session));
message = rb_str_new_cstr(ssh_get_error(session));
argv[0] = message;
exc = rb_class_new_instance(1, argv, rb_eLibSSHError);
rb_ivar_set(exc, id_code, code);
rb_exc_raise(exc);
}
开发者ID:sorah,项目名称:libssh-ruby,代码行数:12,代码来源:error.c
示例15: rval2gslist_rescue
static VALUE
rval2gslist_rescue(VALUE data, VALUE e)
{
struct rval2gslist_args *args = (struct rval2gslist_args *)data;
g_slist_free(args->list);
args->list = NULL;
rb_exc_raise(e);
return Qnil;
}
开发者ID:adamhooper,项目名称:ruby-gnome2,代码行数:12,代码来源:rbgutil_list.c
示例16: yajl_parse_chunk
void yajl_parse_chunk(const unsigned char * chunk, unsigned int len, yajl_handle parser) {
yajl_status stat;
stat = yajl_parse(parser, chunk, len);
if (stat != yajl_status_ok && stat != yajl_status_insufficient_data) {
unsigned char * str = yajl_get_error(parser, 1, chunk, len);
VALUE errobj = rb_exc_new2(cParseError, (const char*) str);
yajl_free_error(parser, str);
rb_exc_raise(errobj);
}
}
开发者ID:curtosis,项目名称:lucite,代码行数:12,代码来源:yajl_ext.c
示例17: executeRescue
VALUE executeRescue(VALUE transaction, VALUE error)
{
//fprintf( stderr, "recuse, operation failed\n" );
rb_funcall(transaction, rb_intern("rollback"), 0);
rb_exc_raise(error);
return(Qnil);
}
开发者ID:wndxlori,项目名称:ibruby,代码行数:12,代码来源:Connection.c
示例18: cr_user_font_face_invoke_rescue
static VALUE
cr_user_font_face_invoke_rescue (VALUE user_data, VALUE exception)
{
cr_user_font_face_invoke_data_t *data;
data = (cr_user_font_face_invoke_data_t *)user_data;
*(data->status) = rb_cairo__exception_to_status (exception);
if (*(data->status) == (cairo_status_t)-1)
rb_exc_raise (exception);
return Qnil;
}
开发者ID:rcairo,项目名称:rcairo,代码行数:13,代码来源:rb_cairo_font_face.c
示例19: rollback_subtransaction
VALUE
rollback_subtransaction( VALUE ary)
{
VALUE cmd;
cmd = rb_str_buf_new2( "rollback to savepoint ");
rb_str_buf_append( cmd, rb_ary_entry( ary, 1));
rb_str_buf_cat2( cmd, ";");
pgresult_clear( pg_statement_exec( rb_ary_entry( ary, 0), cmd, Qnil));
rb_ary_store( ary, 1, Qnil);
rb_exc_raise( RB_ERRINFO);
return Qnil;
}
开发者ID:BertramScharpf,项目名称:ruby-pgsql,代码行数:13,代码来源:conn_exec.c
示例20: oci8_do_raise_init_error
void oci8_do_raise_init_error(const char *file, int line)
{
VALUE msg = rb_usascii_str_new_cstr("OCI Library Initialization Error");
VALUE exc;
const char *dll_path = oci8_dll_path();
if (dll_path != NULL) {
msg = rb_str_buf_cat_ascii(msg, " - ");
msg = rb_enc_str_buf_cat(msg, dll_path, strlen(dll_path), rb_filesystem_encoding());
}
exc = rb_class_new_instance(1, &msg, eOCIError);
rb_exc_raise(set_backtrace(exc, file, line));
}
开发者ID:Captnwalker1,项目名称:ruby-oci8,代码行数:13,代码来源:error.c
注:本文中的rb_exc_raise函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论