error checks in the correct order resulting in the wrong error code sometimes being returned. [RT #19249]