From 8aca5e30d40d058b8ea7dc2120d4001f4d3043a0 Mon Sep 17 00:00:00 2001 From: "BOITARD Nicolas (Externe)" <123453373+boitardn@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:31:45 +0200 Subject: [PATCH] fread_antares() shiny compatible with additional processing of the error messages if a shiny application is running --- NAMESPACE | 1 + NEWS.md | 2 +- R/utils_api.R | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index deb945ef..1dca5501 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -104,6 +104,7 @@ importFrom(plyr,llply) importFrom(purrr,quietly) importFrom(shiny,getDefaultReactiveDomain) importFrom(shiny,incProgress) +importFrom(shiny,isRunning) importFrom(shiny,withProgress) importFrom(stats,as.formula) importFrom(stats,setNames) diff --git a/NEWS.md b/NEWS.md index d734f891..ff77eb86 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,7 +12,7 @@ NEW FEATURES: It contains a table with group dimensions of time series for binding constraints. * `readAntares()` new parameter **clustersST** to read (output simulation) short-term clusters * New function `readAntaresSTClusters()` - +* `fread_antares()` shiny compatible with a conditional processing of the error messages BREAKING CHANGES : diff --git a/R/utils_api.R b/R/utils_api.R index 562e31cd..4a2ce515 100644 --- a/R/utils_api.R +++ b/R/utils_api.R @@ -1,4 +1,5 @@ #' @importFrom utils URLencode +#' @importFrom shiny isRunning fread_antares <- function(opts, file, ...) { if (identical(opts$typeLoad, "api")) { file <- gsub("\\.txt$", "", file) @@ -9,7 +10,10 @@ fread_antares <- function(opts, file, ...) { ) suppressWarnings( tryCatch(fread(response, ...), error = function(e){ - message(file); message(e) + if(isRunning()) + e <- as.character(e) + message(file) + message(e) })) } else { suppressWarnings(