Extracting stacktrace generation logic to separate class