Skip to content

Commit

Permalink
use cli::cli_warn() everywhere for warnings (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored Nov 13, 2024
1 parent 08c2c63 commit df8ce80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
22 changes: 7 additions & 15 deletions R/plot_aggregate_loanbooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ plot_aggregate_loanbooks <- function(config) {
nodes_order_from_data = TRUE
)
} else {
warning("Sankey plot (by sector) cannot be generated. Skipping!")
cli::cli_warn("Sankey plot (by sector) cannot be generated. Skipping!")
}

if (!is.null(company_aggregated_alignment_net)) {
Expand Down Expand Up @@ -198,7 +198,7 @@ plot_aggregate_loanbooks <- function(config) {
png_name = glue::glue("plot_{output_file_sankey_company_sector}.png")
)
} else {
warning("Sankey plot (by sector and company) cannot be generated. Skipping!")
cli::cli_warn("Sankey plot (by sector and company) cannot be generated. Skipping!")
}

### scatter plot alignment by exposure and sector comparison----
Expand Down Expand Up @@ -252,7 +252,7 @@ plot_aggregate_loanbooks <- function(config) {
)
}
} else {
warning("Scatter plot exposure by alignment cannot be generated. Skipping!")
cli::cli_warn("Scatter plot exposure by alignment cannot be generated. Skipping!")
}

### scatter plot for group level comparison----
Expand Down Expand Up @@ -311,9 +311,7 @@ plot_aggregate_loanbooks <- function(config) {
)
}
} else {
warning(
glue::glue("Scatter plot BO/PO cannot be generated. Skipping!")
)
cli::cli_warn("Scatter plot BO/PO cannot be generated. Skipping!")
}

# power
Expand Down Expand Up @@ -369,9 +367,7 @@ plot_aggregate_loanbooks <- function(config) {
)
}
} else {
warning(
glue::glue("Scatter plot BO/PO cannot be generated. Skipping!")
)
cli::cli_warn("Scatter plot BO/PO cannot be generated. Skipping!")
}

# group level plots ----
Expand Down Expand Up @@ -466,9 +462,7 @@ plot_aggregate_loanbooks <- function(config) {
}
}
} else {
warning(
glue::glue("Scatter plot BO/PO cannot be generated at company level. Skipping!")
)
cli::cli_warn("Scatter plot BO/PO cannot be generated at company level. Skipping!")
}

# power
Expand Down Expand Up @@ -532,8 +526,6 @@ plot_aggregate_loanbooks <- function(config) {
}
}
} else {
warning(
glue::glue("Scatter plot BO/PO cannot be generated at company level. Skipping!")
)
cli::cli_warn("Scatter plot BO/PO cannot be generated at company level. Skipping!")
}
}
2 changes: 1 addition & 1 deletion R/plot_scatter.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ plot_scatter <- function(data,
caption <- glue::glue("{caption}Region: {r2dii.plot::to_title(region)}", .trim = FALSE)
}
} else {
rlang::warn("No information to display in caption provided. Please provide scenario_source and/or scenario and/or region if you want them to be included in the graph", frequency = "once")
cli::cli_warn("No information to display in caption provided. Please provide scenario_source and/or scenario and/or region if you want them to be included in the graph", frequency = "once")
}

if (is.null(title)) {
Expand Down
2 changes: 1 addition & 1 deletion R/prepare_sector_split.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ prepare_sector_split <- function(config) {
config <- load_config(config)

if (!get_apply_sector_split(config)) {
warning("`apply_sector_split` is `FALSE` in your config, so the `prepare_sector_split()` function will do nothing.")
cli::cli_warn("{.arg apply_sector_split} is {.val FALSE} in your config, so the {.fn prepare_sector_split} function will do nothing.")
return(invisible())
}

Expand Down

0 comments on commit df8ce80

Please sign in to comment.