fixes a `this` scoping issue in error handling