collect_note_if: Conditionally add note to list

View source: R/dev.R

collect_note_ifR Documentation

Conditionally add note to list

Description

Add an entry to a list if condition is TRUE

Usage

collect_note_if(msg_list, new_msg, condition, newline = TRUE)

Arguments

msg_list

A list of messages

new_msg

A new message to add to msg_list

condition

If TRUE, then add new_msg to msg_list; else, msg_list remains unchanged

newline

If TRUE, then add a new line to new_msg before appending to msg_list

Details

Before this function, error messages would be sent one at a time. Resultantly, users would spend time in a cycle of: run code, debug code, and repeat. However, it would be more efficient if the user received all possible error messages, rather than just the first error message, and then start debugging. This would ease the debugging process and perhaps later errors would provide insight into fixing the current error.

This function was created with the intention of collecting error messages in a list, and then printing all the error messages at the end. The hope was that users can debug all at one go, rather than debug incrementally.

The goal is to pass this list to stop, warning, etc. To print each message on its own line, set newline to TRUE.

msg_list must be a list; new_msg must be a string; and condition and newline must be booleans.

Value

If add is TRUE, then the result will be all the messages in msg_list. Else, the function returns msg_list.

See Also

Other dev: send_note_if()


omkarakatta/ivqr documentation built on Aug. 20, 2022, 11:04 p.m.