You need to explicitly pass the stacktrace as argument from the catch block. By calling another function, you may modify the stacktrace (it happens when the module is first accessed at runtime for example).