bptry {BiocParallel} | R Documentation

## Try expression evaluation, recovering from bperror signals

### Description

This function is meant to be used as a wrapper around `bplapply()` and friends, returning the evaluated expression rather than signalling an error.

### Usage

    bptry(expr, ..., bplist_error, bperror)

### Arguments

`expr` | An R expression; see `tryCatch`.
`bplist_error` | A ‘handler’ function of a single argument, used to catch `bplist_error` conditions signalled by `expr`. A `bplist_error` condition is signalled when an element of `bplapply` and other iterations contain a evaluation that failed. When missing, the default retrieves the “result” attribute from the error, containing the partially evaluated results. Setting `bplist_error=identity` returns the evaluated condition. Setting `bplist_error=stop` passes the condition to other handlers, notably the handler provided by `bperror`.
`bperror` | A ‘handler’ function of a single argument, use to catch `bperror` conditions signalled by `expr`. A `bperror` is a base class to all errors signaled by BiocParallel code. When missing, the default returns the condition without signalling an error.
`...` | Additional named handlers passed to `tryCatch()`. These user-provided handlers are evaluated before default handlers `bplist_error`, `bperror`.

### Value

The partially evaluated list of results.

### Author(s)

Martin Morgan martin.morgan@roswellpark.org

### See Also

`tryCatch`, `bplapply`.

### Examples

    param = registered()[[1]]
    param
    X = list(1, "2", 3)
    bptry(bplapply(X, sqrt))                         # bplist_error handler
    bptry(bplapply(X, sqrt), bplist_error=identity)  # bperror handler

[Package BiocParallel version 1.21.2 Index]