G-5010: Always use an error/logging framework for your application.

Critical

Reliability, Reusability, Testability

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 error messages to a user friendly error text
  • Error repository

By far, the best logging framework available is Logger from OraOpenSource.

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;
/