Adds options.stackFunction for passing to error.prepareStackTrace

Fixes issues in #47