Applying errorHandle bug fix from master to 3.x branch