How can I get the stack trace for a JavaScript exception in IE 8?

In Internet Explorer 8 and earlier versions, you can use the error object to get the stack trace of a thrown exception. Here’s an example of how you can modify the code to log the stack trace: resolveWith: function( context, args ) { if ( !cancelled && !fired && !firing ) { firing = 1; … Read more

Oracle PL/SQL: how to get the stack trace, package name and procedure name

You probably want DBMS_UTILITY.FORMAT_ERROR_BACKTRACE function SQL> ed Wrote file afiedt.buf 1 create or replace procedure p1 2 is 3 begin 4 raise_application_error( -20001, ‘Error 1’, true ); 5* end; SQL> / Procedure created. SQL> create or replace procedure p2 2 as 3 begin 4 null; 5 p1; 6 end; 7 / Procedure created. SQL> begin … Read more

Log4j formatting: Is it possible to truncate stacktraces?

You can use a EnhancedPatternLayout in log4j to format your stacktraces. See http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/EnhancedPatternLayout.html, specifically the section about the “throwable” pattern in the pattern table. Note that support for the %throwable{n} support is rather new and requires at least log4j 1.2.16 (which is the latest at time of writing) For tracking purposes, this is the ticket … Read more

When will proper stack traces be provided on window.onError function?

The error object, which would contain a “sanitized” stack trace, is now being passed in as the fifth parameter to onerror in Chrome. You can read about it here: https://code.google.com/p/chromium/issues/detail?id=147127 At the time of this writing it’s in Canary and should be pushed out to the stable Chrome release sometime later this month. If you’re … Read more

How to get line number(s) in the StackTrace of an exception thrown in .NET to show up

To get the line numbers in the StackTrace, you need to have the correct debug information (PDB files) alongside your dlls/exes. To generate the the debug information, set the option in Project Properties -> Build -> Advanced -> Debug Info: Setting it to full should suffice (see the Advanced Build Settings Dialog Box docs for … Read more

Java logger that automatically determines caller’s class name

The MethodHandles class (as of Java 7) includes a Lookup class that, from a static context, can find and return the name of the current class. Consider the following example: import java.lang.invoke.MethodHandles; public class Main { private static final Class clazz = MethodHandles.lookup().lookupClass(); private static final String CLASSNAME = clazz.getSimpleName(); public static void main( String … Read more