The definition on an exception is a definition - just like any other variable.
Anyone having access to the package can use it, if you put it in the package spec.
If that’s not necessary or desired, I’d put the definition at the top of the package body.
It is good coding style - to be able to reuse the same exception in other places i.o. having to redefine them over and over again (possibly with different names).
I’ve generated inline comments for the 541 advice (see below), and this makes it clear why they flag it for all global public variables.
It might be a good idea to make an exception (pun intended) for exceptions, though…
PACKAGE test
IS
error_size exception;
/*ADVICE(3): Global public variables defined in package specification
[541] */
END test;
/* ADVICE:
ADVICE SUMMARY
Count Recommendation
1 [541] Global public variables defined in package specification
You should always declare package-level data inside the
package body. You can then define "get and set" programs
(function and procedure, respectively) in the package
specification to provide controlled access to that data.
With this approach, you can guarantee data integrity,
change your data structure implementation, and also track
access to those data structures.
Hi Filipe, because the changes need to be done by formatter team but they are working on other tasks, we still have to wait :(. I would say we may have it fixed in the second half of this year when we get the new advisor available.