Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions R/addins.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ style_active_file <- function() {
try_transform_as_r_file <- function(context, transformer) {
tryCatch(
transformer(context$contents),
error = function(e) stop(
paste(
"Styling of unsaved files is only supported for R files with valid code.",
"Please save the file (as .R or .Rmd) and make sure that the R code in it",
"can be parsed. Then, try to style again.",
"The error was \n", e
), call. = FALSE
error = function(e) {
preamble_for_unsaved <- paste(
"Styling of unsaved files is only supported for R files with valid code.",
"Please save the file (as .R or .Rmd) and make sure that the R code in it",
"can be parsed. Then, try to style again."
)

if (context$path == "") {
stop(paste0(preamble_for_unsaved, "The error was \n", e), call. = FALSE)
} else {
stop(e)
}
}
)
}

Expand Down