void oci8_do_raise_by_msgno(ub4 msgno, const char *default_msg, const char *file, int line) { VALUE msg = oci8_get_error_message(msgno, default_msg); VALUE exc = rb_funcall(eOCIError, oci8_id_new, 2, msg, INT2FIX(-1)); rb_exc_raise(set_backtrace(exc, file, line)); }
void oci8_do_raise_by_msgno(ub4 msgno, const char *default_msg, const char *file, int line) { VALUE msg = oci8_get_error_message(msgno, default_msg); VALUE args[2]; args[0] = msg; args[1] = INT2FIX(-1); rb_exc_raise(set_backtrace(rb_class_new_instance(2, args, eOCIError), file, line)); }
/* * call-seq: * OCI8.error_message(message_no) -> string * * Get the Oracle error message specified by message_no. * Its language depends on NLS_LANGUAGE. * * Note: This method is unavailable if the Oracle client version is 8.0. * * example: * # When NLS_LANG is AMERICAN_AMERICA.AL32UTF8 * OCI8.error_message(1) # => "ORA-00001: unique constraint (%s.%s) violated" * * # When NLS_LANG is FRENCH_FRANCE.AL32UTF8 * OCI8.error_message(1) # => "ORA-00001: violation de contrainte unique (%s.%s)" * */ static VALUE oci8_s_error_message(VALUE klass, VALUE msgid) { return oci8_get_error_message(NUM2UINT(msgid), NULL); }