Catch URL parse errors in q.print

Change-Id: Id84e3289385055dcae991b76df1283e49aca691a
diff --git a/R/KorAPQuery.R b/R/KorAPQuery.R
index 01e48cb..e6de2a9 100644
--- a/R/KorAPQuery.R
+++ b/R/KorAPQuery.R
@@ -500,22 +500,27 @@
 #' @rdname KorAPQuery-class
 #' @param x KorAPQuery object
 #' @param ... further arguments passed to or from other methods
+#' @importFrom httr2 url_parse
 #' @export
 format.KorAPQuery <- function(x, ...) {
   cat("<KorAPQuery>\n")
   q <- x
-  aurl = url_parse(q@request)
-  cat("           Query: ", aurl$query$q, "\n")
-  if (!is.null(aurl$query$cq) && aurl$query$cq != "") {
-    cat("  Virtual corpus: ", aurl$query$cq, "\n")
-  }
-  if (!is.null(q@collectedMatches)) {
-    cat("==============================================================================================================", "\n")
-    print(summary(q@collectedMatches))
-    cat("==============================================================================================================", "\n")
-  }
-  cat("   Total results: ", q@totalResults, "\n")
-  cat(" Fetched results: ", q@nextStartIndex, "\n")
+  tryCatch({
+    aurl = httr2::url_parse(q@request)
+    cat("           Query: ", aurl$query$q, "\n")
+    if (!is.null(aurl$query$cq) && aurl$query$cq != "") {
+      cat("  Virtual corpus: ", aurl$query$cq, "\n")
+    }
+    if (!is.null(q@collectedMatches)) {
+      cat("==============================================================================================================", "\n")
+      print(summary(q@collectedMatches))
+      cat("==============================================================================================================", "\n")
+    }
+    cat("   Total results: ", q@totalResults, "\n")
+    cat(" Fetched results: ", q@nextStartIndex, "\n")
+  }, error = function(e) {
+    cat("Error parsing URL: ", e$message, "\n")
+  })
 }
 
 #' show()