R: 'tryCatch' both warnings (with value) and errors

vsn.tryCatch.W.E {asreml} | R Documentation

## `tryCatch` both warnings (with value) and errors

### Description

Catch and save both errors and warnings, and in the case of a warning, also keep the computed result.

### Usage

    vsn.tryCatch.W.E(expr)

### Arguments

`expr` | An R expression to evaluate.

### Value

A list with "value" and "warning", where "value" may be an error caught.

### Note

This has been altered from the original to return multiple warnings as a list if more than one is thrown in `expr` and hence has been renamed.

The original was taken from https://stackoverflow.com/questions/32076454/save-object-that-threw-warning-using-trycatch

Original author: Martin Maechler;

Original copyright statement: Copyright (C) 2010-2012 The R Core Team

[Package asreml version 4.2.0.480 Index]