@@ -39,6 +39,9 @@ body_add_crosstable = function (doc, x, body_fontsize=NULL,
3939 padding_v = NULL ,
4040 allow_break = TRUE ,
4141 max_cols = 25 , ... ) {
42+ if (is.null(x )){
43+ cli_abort(" {caller_arg(x)} is NULL" )
44+ }
4245 assert_class(x , " crosstable" , .var.name = vname(x ))
4346
4447 if (missing(padding_v )) padding_v = getOption(" crosstable_padding_v" , NULL )
@@ -686,7 +689,7 @@ body_add_img2 = function(doc, src, width, height,
686689# ' @author Dan Chaltiel
687690# ' @export
688691# ' @importFrom checkmate assert_class
689- # ' @importFrom rlang check_installed
692+ # ' @importFrom rlang caller_arg check_installed
690693# ' @examples
691694# ' library(officer)
692695# ' library(ggplot2)
@@ -709,6 +712,9 @@ body_add_gg2 = function(doc, value,
709712 add_legend = TRUE , bookmark = NULL ,
710713 res = 300 , ... ){
711714 check_installed(" ggplot2" , reason = " for function `body_add_gg2()` to work." )
715+ if (is.null(value )){
716+ cli_abort(" {caller_arg(value)} is NULL" )
717+ }
712718 assert_class(value , " ggplot" )
713719 units = match.arg(units , c(" in" , " cm" , " mm" ))
714720 file = tempfile(fileext = " .png" )
@@ -749,6 +755,9 @@ body_add_gg2 = function(doc, value,
749755# ' write_and_open(doc)
750756body_add_flextable2 = function (doc , x , bookmark = NULL , append_line = TRUE , ... ){
751757 legend = attr(x , " legend" )
758+ if (is.null(x )){
759+ cli_abort(" {caller_arg(x)} is NULL" )
760+ }
752761 if (! is.null(legend )){
753762 doc = body_add_table_legend(doc , legend = legend , bookmark = bookmark )
754763 }
0 commit comments