Learn R Programming

zmisc (version 0.2.3)

wrap_error: Utility function to output an error

Description

This function is used to capture errors, typically inside a tryCatch() statement and output them in a clean and readable way. The function provides line-wrapping, with a configurable width. When printing the error message, it prefixes the text with "#E> " to make it easier to look for the error.

Usage

wrap_error(e, wrap = 50)

Value

The original error is returned invisibly.

Arguments

e

The error to wrap.

wrap

How many characters per line before wrapping.

Examples

Run this code
tryCatch(stop("This is an error"), error=wrap_error)

Run the code above in your browser using DataLab