diff --git a/R/rlistings_methods.R b/R/rlistings_methods.R index d5ca8d6f..ef11bc86 100644 --- a/R/rlistings_methods.R +++ b/R/rlistings_methods.R @@ -15,16 +15,23 @@ dflt_courier <- font_spec("Courier", 9, 1) #' @export #' @name listing_methods print.listing_df <- function(x, widths = NULL, tf_wrap = FALSE, max_width = NULL, fontspec = NULL, col_gap = 3L, ...) { - cat( - toString( - matrix_form(x, fontspec = fontspec, col_gap = col_gap), - widths = widths, - tf_wrap = tf_wrap, - max_width = max_width, - fontspec = fontspec, - col_gap = col_gap, - ... + tryCatch({ + cat( + toString( + matrix_form(x, fontspec = fontspec, col_gap = col_gap), + widths = widths, + tf_wrap = tf_wrap, + max_width = max_width, + fontspec = fontspec, + col_gap = col_gap, + ... + ) ) + }, error = function(e) { + if (nrow(x) == 0){ + print("No observation in the listing object.") + } + } ) invisible(x) }