How to detect certain keywords in the error message returned from Google Maps API?

Hi all, I am currently trying to find a way to read the error message returned by Google Maps API via the use of gmapsdistance() function to see if it contains certain keywords. Does anyone know how to achieve this? The error message itself, when being contained in the error = function(error_message) part of tryCatch{expr = {...}, error = function(error_message){...}, seems not to be a text so neither grepl(,...error_message) nor str_detect(, error_message) work.