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

Dan Tenenbaum dtenenba at fredhutch.org
Wed Mar 9 20:48:06 CET 2016


Staying out of the debate as to whether to emit a long error message or direct the user to the relevant man page, I will say that whether the error message is long or short, it should still direct the user to the relevant man page, where the way to avoid the error should be discussed in full. That way the careful user who reads documentation will find out how to avoid the error before actually encountering it.

Dan


----- Original Message -----
> From: "Hervé Pagès" <hpages at fredhutch.org>
> To: "Michael Love" <michaelisaiahlove at gmail.com>, "bioc-devel" <bioc-devel at r-project.org>
> Sent: Wednesday, March 9, 2016 11:38:48 AM
> Subject: Re: [Bioc-devel] best practice for storing long error message in R package

> 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
> 
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel



More information about the Bioc-devel mailing list