Skip to content

call arg ignored for .internal = TRUE in cli_abort() #1386

@salim-b

Description

@salim-b

cli::cli_abort(.internal = TRUE) internal error messages always assume the error would be in the cli package, regardless of call. rlang::abort(.internal = TRUE) doesn't have this problem.

good <- function() rlang::abort("oops", call = rlang::caller_env(), .internal = TRUE)
bad <- function() cli::cli_abort("oops", call = rlang::caller_env(), .internal = TRUE)

good()
#> Error:
#> ! oops
#> ℹ This is an internal error, please report it to the package authors.
bad()
#> Error:
#> ! oops
#> ℹ This is an internal error in the cli package, please report it to the package
#>   authors.

Created on 2022-03-31 by the reprex package (v2.0.1)

I think the underlying issue is in rlang::abort():

rlang/R/cnd-abort.R

Lines 300 to 307 in 9d8e74f

message_info <- cnd_message_info(
message,
body,
footer,
caller,
use_cli_format = use_cli_format,
internal = .internal
)
uses cnd_message_info(call = caller) but instead should be cnd_message_info(call = call) because caller <- caller_env().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions