[Bioc-devel] best practice for storing long error message in R package

Hervé Pagès hpages at fredhutch.org
Wed Mar 9 20:38:48 CET 2016


Hi Mike,

Not saying this is best practice but personally I like to keep the error
message close to the function itself. This makes maintenance easier as
otherwise it would be easy to forget to update the error message when
the behavior of the function is changed.

.foo_very_long_error_msg <- c(
     "This is a very long error message etc etc ",
     "etc etc etc ",
     "etc etc etc ",
     ...
)

foo <- function(...)
{
     ...
     if (...)
         stop(wmsg(.foo_very_long_error_msg))
     ...
}

wmsg() is a little helper defined in S4Vectors that wraps the error
message to fit in a console of width getOption("width").

Just my 2 cents.

H.

On 03/09/2016 07:19 AM, Michael Love wrote:
> hi,
>
> I have a long error message I want to print out after failing on some
> condition, but don't want this long message taking up space in the
> body of the function. I'm curious what other developers think would be
> best practice for where/how to store this message content in a
> package.
>
> best,
> Mike
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list