[fix] Consistent error handling in before and after hooks. cc/ @mmalecki.