From 5acd465c001b14a3d0ce5fba36918bac05d6d0d2 Mon Sep 17 00:00:00 2001 From: Joshua Sturm <22535419+JoshuaSturm@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:20:07 -0400 Subject: [PATCH] Print description in assert error summary --- NEWS | 2 ++ R/errors.R | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index de37f88..ffa4dd5 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ # assertr development version +* Assert errors now print the description in the error summary (PR #132) + * Added the ability to check non-numeric classes with `within_bounds()` (fix #89) diff --git a/R/errors.R b/R/errors.R index 38b0d01..068ebb5 100644 --- a/R/errors.R +++ b/R/errors.R @@ -148,6 +148,10 @@ print.assertr_defect <- function(x, ...){ #' #' @export summary.assertr_assert_error <- function(object, ...){ + if (!is.na(object$description)) { + cat(object$description) + cat("\n") + } cat(object$message) cat("\n") numrows <- nrow(object$error_df)