diff --git a/R/R/bridgestan.R b/R/R/bridgestan.R index 34e4a8ca..57fb1079 100755 --- a/R/R/bridgestan.R +++ b/R/R/bridgestan.R @@ -347,6 +347,9 @@ handle_error <- function(lib_name, err_msg, err_ptr, function_name) { return(paste("Unknown error in", function_name)) } else { .C("bs_free_error_msg_R", as.raw(err_ptr), PACKAGE = lib_name) + if (getOption("warning.length") < nchar(err_msg)) { + warning("BridgeStan error message too long to fully display. Consider increasing options(warning.length)") + } return(err_msg) } } diff --git a/R/R/compile.R b/R/R/compile.R index c2b5da14..b94c8222 100644 --- a/R/R/compile.R +++ b/R/R/compile.R @@ -47,13 +47,13 @@ get_bridgestan_path <- function() { "environment variable, downloading version ", packageVersion("bridgestan"), " to ", path)) get_bridgestan_src() + print("Done!") }) num_files <- length(list.files(HOME_BRIDGESTAN)) if (num_files >= 5) { warning(paste0("Found ", num_files, " different versions of BridgeStan in ", HOME_BRIDGESTAN, ". Consider deleting old versions to save space.")) } - print("Done!") } return(path) @@ -101,8 +101,13 @@ compile_model <- function(stan_file, stanc_args = NULL, make_args = NULL) { }) res_attrs <- attributes(res) if ("status" %in% names(res_attrs) && res_attrs$status != 0) { - stop(paste0("Compilation failed with error code ", res_attrs$status, "\noutput:\n", - paste(res, collapse = "\n"))) + error_msg <- paste0("Compilation failed with error code ", res_attrs$status, + "\noutput:\n", paste(res, collapse = "\n")) + + if (getOption("warning.length") < nchar(error_msg)) { + warning("BridgeStan error message too long to fully display. Consider increasing options(warning.length)") + } + stop(error_msg) } return(output)