function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert Cram NLRobert Cram NL 

Exception.getStackTraceString() stopped working in Spring '16?

Hi All,

Since the Spring '16 update a lot of my tests went in the red. It seems that the exception.getStackTraceString() method doesn't return any info anymore. Is anyone else seeing this?

I use the getStackTraceString() method to get info about the class in which the exception occurred. Does anyone know a workaround?

Regards,
Robert.
bob_buzzardbob_buzzard
I'm seeing the same thing in my pre-release org. There's nothing on the known issues list at the moment.
Matt Matt 
Known issue has been documented here:
https://success.salesforce.com/issues_view?id=a1p300000008dVIAAY

This demonstrates the spurious behaviour:
@IsTest class StackTraceStringTest {
    
    class CustomException extends Exception {}
    
    static testmethod void testCustomExceptionNotEmpty() {
        Exception e = new CustomException('kaboom');
        String stackTraceString = e.getStackTraceString();
        System.assertNotEquals('()', stackTraceString, 'wrong string');
    }
    
    static testmethod void testNativeExceptionNotEmpty() {
        Exception e = new NullPointerException();
        String stackTraceString = e.getStackTraceString();
        System.assertNotEquals('()', stackTraceString, 'wrong string');
    }
    
}