Toad World® Forums

exection error message check


#1

Hi , how can I put test on error message ?
for example i’ve the following procedure :
create or replace procedure mytest(a number) is
begin
raise_Application_error(-20001,‘error is:’||a);
end;

i want to test that error code is 20001 and the error message has number 1 .

how can i do it ?


#2

Currently, you can only test for exceptions directly by checking the error code. So you can simply choose Exception at the type of data that is being tested (top left field in the outcome grid), and then provide the Onumber -20001 as the expected value.

If you want to check the error message, then:

  1. Add a new outcome
  2. Choose Expression as the type of data that was Changed by Program.
  3. Press the […] button below, set the type of the Expression to VARCHAR2.
  4. Enter the following code in the expression code window:

DBMS_UTILITY.FORMAT_ERROR_STACK

  1. Press OK and then decide how you want to test this string. You could test for equality ( = operator) and type in the entire string, you could choose “contains” and type in a portion of the string you want to match against.

Let me know if this does the trick.


#3

Hi , I can’t defined it in 1.6 beta. I got unrecoverable error , when I
try to save the test case. (it seems also the email doesn’t work
correctly ) .

I will try to use 1.5 .


#4

What beta version are you using?


#5

The trick with DBMS_UTILITY.FORMAT_ERROR_STACK alone doesn’t work in 1.8.6.457

But if you add an extra outcome ‘Exception - raises any error’ or an outcome ‘Exception - raises’ with the expected number it will work.