Properly fail on httr get fails

Change-Id: If4fda472040bd282dde7d2a0230a39918dbf88f7
diff --git a/R/matomoquery.R b/R/matomoquery.R
index d30fc32..e530d4b 100644
--- a/R/matomoquery.R
+++ b/R/matomoquery.R
@@ -67,21 +67,11 @@
   ) -> res
 
   if (status_code(res) != 200) {
-    if (json && !http_type(res) %in% c("application/json", "application/ld+json")) {
-      stop("API did not return json", call. = FALSE)
-    }
-    result <- jsonlite::fromJSON(content(res, "text", encoding = "UTF-8"))
-    if (!is.null(result$warnings)) {
-      message <- if (nrow(result$warnings) > 1)
-        sapply(result$warnings, function(warning) paste(sprintf("%s: %s", warning[1], warning[2]), sep="\n"))
-      else
-        sprintf("%s: %s", result$warnings[1], result$warnings[2])
-      warning(message, call. = FALSE)
-    }
+    stop(paste("API call failed:", httr::content(res, "text", encoding = "UTF-8")), call. = FALSE)
   }
 
   if (!http_type(res) %in% c("application/json", "application/ld+json")) {
-    stop("API did not return json", call. = FALSE)
+    stop(paste("API did not return json:", httr::content(res, "text", encoding = "UTF-8")), call. = FALSE)
   }
 
   json <- httr::content(res, "text", encoding = "UTF-8")