diff --git a/R/format-conditions.R b/R/format-conditions.R index 57c242108..db5ea6559 100644 --- a/R/format-conditions.R +++ b/R/format-conditions.R @@ -57,7 +57,7 @@ format_error <- function(message, .envir = parent.frame()) { })(), collapse = TRUE, strip_newline = TRUE) # remove "Error: " that was only needed for the wrapping - formatted1[1] <- sub("Error: ", "", formatted1[1]) + formatted1[1] <- sub("Error:[ ]?", "", formatted1[1]) update_rstudio_color(formatted1) } diff --git a/tests/testthat/test-format-conditions.R b/tests/testthat/test-format-conditions.R index aafe51613..4b411613e 100644 --- a/tests/testthat/test-format-conditions.R +++ b/tests/testthat/test-format-conditions.R @@ -165,3 +165,7 @@ test_that_cli("suppressing Unicode bullets", { ))) })) }) + +test_that("edge cases", { + expect_equal(cli::format_error(""), "") +})