@@ -108,23 +108,21 @@ replace_dot_alias = function(e) {
108108 fixed = TRUE
109109)
110110.checkTypos = function (err , ref ) {
111- idx = regexpr(.missing_obj_regex , err $ message , perl = TRUE )
112- if (idx > 0L ) {
113- start = attr(idx , " capture.start" , exact = TRUE )[ , " obj_name" ]
114- used = substr(
115- err $ message ,
116- start ,
117- start + attr(idx , " capture.length" , exact = TRUE )[ , " obj_name" ] - 1L
118- )
119- found = agrep(used , ref , value = TRUE , ignore.case = TRUE , fixed = TRUE )
120- if (length(found )) {
121- stopf(" Object '%s' not found. Perhaps you intended %s" , used , brackify(found ))
122- } else {
123- stopf(" Object '%s' not found amongst %s" , used , brackify(ref ))
124- }
111+ err_str <- conditionMessage(err )
112+ idx = regexpr(.missing_obj_regex , err_str , perl = TRUE )
113+ if (idx == - 1L )
114+ stopf(" %s" , err_str , domain = NA ) # Don't use stopf() directly, since err_str might have '%', #6588
115+ start = attr(idx , " capture.start" , exact = TRUE )[ , " obj_name" ]
116+ used = substr(
117+ err_str ,
118+ start ,
119+ start + attr(idx , " capture.length" , exact = TRUE )[ , " obj_name" ] - 1L
120+ )
121+ found = agrep(used , ref , value = TRUE , ignore.case = TRUE , fixed = TRUE )
122+ if (length(found )) {
123+ stopf(" Object '%s' not found. Perhaps you intended %s" , used , brackify(found ))
125124 } else {
126- # Don't use stopf() directly, since err$message might have '%', #6588
127- stopf(" %s" , err $ message , domain = NA )
125+ stopf(" Object '%s' not found amongst %s" , used , brackify(ref ))
128126 }
129127}
130128
0 commit comments