handleError: Error handling

Description Usage Arguments Details Value Author(s)

View source: R/utils.R

Description

The handleError function is an internal utility for use by packages extending RGtk2. It decides how to handle an error emitted by GTK+ or one of the other libraries.

Usage

1
handleError(x, .errwarn)

Arguments

x

The result of a call to an underlying library.

.errwarn

DEPRECATED. Whether to emit a warning if there is an error and getOption("RGtk2::newErrorHandling") is FALSE (TRUE is now the default).

Details

There are currently two modes of error handling in RGtk2. One was introduced with RGtk2 2.20.0. It is now the default and will eventually replace the older one. Setting the option RGtk2::newErrorHandling to FALSE disables the newer error handling, to ease the transition of code.

The original behavior is to return a list from every library function that might raise an error. The error component of the list holds the error, while the primary return value of the underlying function is named retval (and there might be additional return values). If there is no error, the error component is NULL. Otherwise, it holds an object of type simpleError (actually until 2.20.0 this was just a list with a very similar structure).

The new approach, active when getOption("RGtk2::newErrorHandling") returns TRUE, will throw any error (as a simpleError object). An error in the underlying library is an error in R. No error object is returned. This often results in a simpler return value, as a list is no longer necessary unless there are multiple return values from the wrapped function. The .errwarn argument is ignored and will soon be removed from the wrappers along with the old error handling, resulting in a simpler API.

Value

x, with the error removed if the "RGtk2::newErrorHandling" option is TRUE.

Author(s)

Michael Lawrence


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to handleError in RGtk2...