From 0463f966ea83fd971c6e578430c8fa951599abce Mon Sep 17 00:00:00 2001 From: hong-revo Date: Sat, 5 May 2018 21:25:59 +1000 Subject: [PATCH] print arm messages on error --- R/{call_azure_sm.R => call_azure_rm.R} | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) rename R/{call_azure_sm.R => call_azure_rm.R} (89%) diff --git a/R/call_azure_sm.R b/R/call_azure_rm.R similarity index 89% rename from R/call_azure_sm.R rename to R/call_azure_rm.R index dc14e72..3e97948 100644 --- a/R/call_azure_sm.R +++ b/R/call_azure_rm.R @@ -35,13 +35,21 @@ call_azure_rm <- function(token, subscription, operation, ..., if(catch != "pass") { catch <- get(paste0(catch, "_for_status"), getNamespace("httr")) - catch(res) + catch(res, arm_error_message(res)) httr::content(res) } else res } +arm_error_message <- function(response) +{ + cont <- httr::content(response) + msg <- paste0(strwrap(cont$error$message), collapse="\n") + paste0("complete Resource Manager operation. Message:\n", msg) +} + + # TRUE for NULL and length-0 objects is_empty <- function(x) { @@ -70,3 +78,4 @@ named_list <- function(lst, name_field="name") } lst } +