Delete errmsg if isn't NULL