Skip to content

Commit 29599cc

Browse files
committed
Display error prefixes in red experimentally
1 parent 81c7dcd commit 29599cc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

R/cnd-message.R

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,13 @@ cnd_message_format_prefixed <- function(cnd,
228228

229229
if (parent) {
230230
prefix <- sprintf("Caused by %s", type)
231+
# FIXME: Enable this by default later on
232+
if (use_red_error_prefix()) {
233+
prefix <- col_prefix(prefix, type)
234+
}
231235
} else {
232-
prefix <- col_yellow(capitalise(type))
236+
prefix <- capitalise(type)
237+
prefix <- col_prefix(prefix, type)
233238
}
234239

235240
evalq({
@@ -270,6 +275,18 @@ cnd_message_format_prefixed <- function(cnd,
270275
}
271276
}
272277

278+
col_prefix <- function(prefix, type) {
279+
if (type == "error" && use_red_error_prefix()) {
280+
col_red(prefix)
281+
} else {
282+
col_yellow(prefix)
283+
}
284+
}
285+
286+
use_red_error_prefix <- function() {
287+
peek_option("rlang:::use_red_error_prefix") %||% FALSE
288+
}
289+
273290
peek_call_format_srcref <- function() {
274291
opt <- peek_option("rlang_call_format_srcrefs")
275292
if (is_null(opt)) {

0 commit comments

Comments
 (0)