Skip to content

G-5010: Try to use a error/logging framework for your application.

Critical

Reliability, Reusability, Testability

Unsupported in db* CODECOP Validators

We cannot identify logging framework and where it should be applied. Requires further definition regarding naming of the error/logging framework and its minimal use in PL/SQL code.

Reason

Having a framework to raise/handle/log your errors allows you to easily avoid duplicate application error numbers and having different error messages for the same type of error.

This kind of framework should include

  • Logging (different channels like table, mail, file, etc. if needed)
  • Error Raising
  • Multilanguage support if needed
  • Translate Oracle Database error messages to a user friendly error text
  • Error repository

Example (bad)

1
2
3
4
5
6
begin
   sys.dbms_output.put_line('START');
   -- some processing
   sys.dbms_output.put_line('END');
end;
/

Example (good)

1
2
3
4
5
6
7
8
9
declare 
   -- see https://github.com/OraOpenSource/Logger
   l_scope logger_logs.scope%type := 'DEMO';
begin
   logger.log('START',l_scope);
   -- some processing
   logger.log('END',l_scope);
end;
/