Fixes bad promise error handling