Factor out stacktrace extraction into function