Including function calls in error messages — topic-error-call
Starting with rlang 1.0, abort() includes the erroring function in the message by default:
my_function <- function() {
abort("Can't do that.")
}
my_function()
#> Error in `my_function()`:
#> ! Can't do that.
This works well when abort() is called directly within the failing function. However, when the abort() call is exported to another function (which we call an "error helper"), we need to be explicit about which function abort() is throwing an error for.
This works well when abort() is called directly within the failing function. However, when the abort() call is exported to another function (which we call an "error helper"), we need to be explicit about which function abort() is throwing an error for.
There are two main kinds of error helpers:
Simple abort() wrappers. These often aim at adding classes and attributes to an error condition in a structured way:
stop_my_class <- function(message) {
abort(message, class = "my_class")
}
Input checking functions. An input checker is typically passed an input and an argument name. It throws an error if the input doesn't conform to expectations:
check_string <- function(x, arg = "x") {
if (!is_string(x)) {
cli::cli_abort("{.arg {arg}} must be a string.")
}
}
To fix this, let abort() know about the function that it is throwing the error for by passing the corresponding function environment as the call argument:
Chapter 6 Mapping Census data with R | Analyzing US Census Data
Data from the United States Census Bureau are commonly visualized using maps, given that Census and ACS data are aggregated to enumeration units. This chapter will cover the process of map-making...
Chapter 5 Census geographic data and applications in R | Analyzing US Census Data
As discussed in previous chapters of this book, Census and ACS data are associated with geographies, which are units at which the data are aggregated. These defined geographies are represented in...
publiclab/leaflet-environmental-layers: Collection of different environmental map layers in an easy to use Leaflet library, similar to https://github.com/leaflet-extras/leaflet-providers#leaflet-providers
Collection of different environmental map layers in an easy to use Leaflet library, similar to https://github.com/leaflet-extras/leaflet-providers#leaflet-providers - publiclab/leaflet-environmenta...
FEMA GIS supports the emergency management community with world-class geospatial information, services, and technologies to prepare for, protect against, respond to, recover from and mitigate against all hazards.
MyGeodata Converter - Convert and transform GIS/CAD data to various formats and coordinate systems, like SHP, KML, KMZ, TAB, CSV, GeoJSON, GML, DGN, DXF...
Course Description & Objectives This course is about different techniques used in assembling, managing, analysing and predicting using heterogeneous data sets in urban environments. These datasets are inherently messy and incomplete.