In fact, ORA-06512 does not throw the actual error it encountered. Instead, it points out the problem line in the PL/SQL program unit in error stack. For example:
2 v_num number;
4 v_num := '2 + 2';
5 dbms_output.put_line('The number is ' || v_num);
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 4
In the above example, ORA-06512 told you that there's an error at line 4 and the true error is ORA-06502.
In real cases, PL/SQL code may be far more complex than this case. All you have to do is to trace the problem from one line to another in the error stack. The true error is usually at the top of the stack.
Please click on the following tag to check more error patterns on ORA-06512.