Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Internal stacktrace showing when cursor fetch raises exception #748

@jgebal

Description

@jgebal

Example:

select ut.version() from dual;

create or replace package jge_tst as
  --%suite
  
  --%test
  procedure tst;
end;
/

create or replace package body jge_tst as
  procedure tst as
    c_price  CONSTANT NUMBER(20,4):= 1357;
    c_user   CONSTANT varchar2(30):= 'TEST_USER';
    v_actual  sys_refcursor;
    v_expected sys_refcursor;
  begin
    open v_actual for
      select cast(null as number(10)) as usd_price_amt, c_user as update_id
        from dual where dummy = 1;
    open v_expected for
      select c_price as usd_price_amt, c_user as update_id from dual;
    ut.expect(v_actual).to_equal(v_expected);
  end;  
end;
/

exec ut.run('jge_tst');

Outcomes:

v3.1.2.2134

Package JGE_TST compiled

Package Body JGE_TST compiled

jge_tst
  tst [.035 sec] (FAILED - 1)
 
Failures:
 
  1) tst
      ORA-19202: Error occurred in XML processing
      ORA-01722: invalid number
      ORA-06512: at "UT3.UT_DATA_VALUE_REFCURSOR", line 96
      ORA-06512: at "UT3.UT_DATA_VALUE_REFCURSOR", line 21
      ORA-06512: at "UT3.UT", line 79
      ORA-06512: at "UT3_TEST.JGE_TST", line 12
      ORA-06512: at line 6
Finished in .037598 seconds
1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)
 
PL/SQL procedure successfully completed.

The exception stacktrace is confusing and suggests that it's internal issue in utPLSQL rather than an issue when executing cursor query.

Maybe we should throw a custom exception and include original exception as well.
So the stack would look like:

  1) tst
      ORA-20000: Exception thrown when fetching data from cursor. 
      ORA-01722: invalid number
      ORA-06512: at "UT3.UT_DATA_VALUE_REFCURSOR", line .... (where exception is thrown)
      ORA-06512: at "UT3.UT", line 79
      ORA-06512: at "UT3_TEST.JGE_TST", line 12
      ORA-06512: at line 6

I'm really not sure if that would help at all.

Any opinions?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions