Reputation: 177
begin
begin
do something;
exception
when no_data_found then
raise_application_error(-20000,"Message");
end;
exception
when others then
raise_application_error(-20000,"Other message");
end;
My problem is when the compiler catches the "Message" error it alsos catches the "Other message" error. Why does it happen?
Upvotes: 0
Views: 94
Reputation: 60493
try to put them in the same exception block.
If you put when others
in a separated block, it will alwasy be raised, as... there's no already catched
exception to exclude from others
in that block.
From doc
The WHEN OTHERS clause is used to trap all remaining exceptions that have not been handled by your Named System Exceptions and Named Programmer-Defined Exceptions.
So
exception
when no_data_found then
raise_application_error(-20000,"Message");
when others then
raise_application_error(-20000,"Other message");
end;
Upvotes: 4