Exception: ODPI::Dpi::Error

Inherits:
StandardError
  • Object
show all
Defined in:
ext/odpi_ext/rbdpi-struct.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object


213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'ext/odpi_ext/rbdpi-struct.c', line 213

static VALUE error_initialize(int argc, VALUE *argv, VALUE self)
{
    error_t *err = TO_ERROR(self);
    VALUE msg;
    VALUE code;
    VALUE offset;
    VALUE fn_name;
    VALUE action;
    VALUE sql_state;
    VALUE is_recoverable;

    rb_scan_args(argc, argv, "07", &msg, &code, &offset, &fn_name, &action, &sql_state, &is_recoverable);

    rb_call_super(argc ? 1 : 0, argv);
    CHK_NSTR(fn_name);
    CHK_NSTR(action);
    CHK_NSTR(sql_state);
    err->code = NIL_P(code) ? 0 : NUM2INT(code);
    err->offset = NIL_P(offset) ? 0 : NUM2UINT(offset);
    err->fn_name = fn_name;
    err->action = action;
    err->sql_state = sql_state;
    err->is_recoverable = RTEST(is_recoverable) ? 1 : 0;
    return self;
}

Instance Method Details

#actionObject


278
279
280
281
282
283
# File 'ext/odpi_ext/rbdpi-struct.c', line 278

static VALUE error_get_action(VALUE self)
{
    error_t *err = TO_ERROR(self);

    return err->action;
}

#codeObject


257
258
259
260
261
262
# File 'ext/odpi_ext/rbdpi-struct.c', line 257

static VALUE error_get_code(VALUE self)
{
    error_t *err = TO_ERROR(self);

    return INT2NUM(err->code);
}

#fn_nameObject


271
272
273
274
275
276
# File 'ext/odpi_ext/rbdpi-struct.c', line 271

static VALUE error_get_fn_name(VALUE self)
{
    error_t *err = TO_ERROR(self);

    return err->fn_name;
}

#initialize_copy(other) ⇒ Object


239
240
241
242
243
# File 'ext/odpi_ext/rbdpi-struct.c', line 239

static VALUE error_initialize_copy(VALUE self, VALUE other)
{
    *TO_ERROR(self) = *TO_ERROR(other);
    return self;
}

#inspectObject


245
246
247
248
249
250
251
252
253
254
255
# File 'ext/odpi_ext/rbdpi-struct.c', line 245

static VALUE error_inspect(VALUE self)
{
    error_t *err = TO_ERROR(self);
    VALUE msg = rb_obj_as_string(self);

    return rb_sprintf("<%s: msg='%.*s', code=%u, offset=%d, fn_name=%.*s, action=%.*s, sql_state=%.*s, is_recoverable=%s>",
                      rb_obj_classname(self),
                      NSTR_LEN_PTR_PAIR(msg), err->code, err->offset,
                      NSTR_LEN_PTR_PAIR(err->fn_name), NSTR_LEN_PTR_PAIR(err->action),
                      NSTR_LEN_PTR_PAIR(err->sql_state), err->is_recoverable ? "true" : "false");
}

#is_recoverable?Boolean

Returns:

  • (Boolean)

292
293
294
295
296
297
# File 'ext/odpi_ext/rbdpi-struct.c', line 292

static VALUE error_is_recoverable_p(VALUE self)
{
    error_t *err = TO_ERROR(self);

    return err->is_recoverable ? Qtrue : Qfalse;
}

#offsetObject


264
265
266
267
268
269
# File 'ext/odpi_ext/rbdpi-struct.c', line 264

static VALUE error_get_offset(VALUE self)
{
    error_t *err = TO_ERROR(self);

    return INT2FIX(err->offset);
}

#sql_stateObject


285
286
287
288
289
290
# File 'ext/odpi_ext/rbdpi-struct.c', line 285

static VALUE error_get_sql_state(VALUE self)
{
    error_t *err = TO_ERROR(self);

    return err->sql_state;
}