From f65d92420e9bb6f4b8d09cbea32c0132638843ce Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 31 Dec 2018 09:43:50 -0800 Subject: [PATCH] government shutdown error catching for ncdc fxns #293 --- DESCRIPTION | 2 +- R/zzz.r | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index ff212d1c..be1b6cbd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: Client for many 'NOAA' data sources including the 'NCDC' climate for 'NOAA' sea ice data, the 'NOAA' severe weather inventory, 'NOAA' Historical Observing 'Metadata' Repository ('HOMR') data, 'NOAA' storm data via 'IBTrACS', tornado data via the 'NOAA' storm prediction center, and more. -Version: 0.8.0.9100 +Version: 0.8.0.9210 License: MIT + file LICENSE Encoding: UTF-8 Language: en-US diff --git a/R/zzz.r b/R/zzz.r index 83be026f..d6c7e46a 100644 --- a/R/zzz.r +++ b/R/zzz.r @@ -86,6 +86,13 @@ check_response <- function(x){ warning(z$status, ": ", z$message) } } else { + # government shutdown check + if ( + grepl("html", x$response_headers$`content-type`) && + grepl("shutdown", x$parse("UTF-8")) + ) { + stop("there's a government shutdown; check back later") + } stopifnot(x$response_headers$`content-type` == 'application/json;charset=UTF-8') res <- x$parse("UTF-8") out <- jsonlite::fromJSON(res, simplifyVector = FALSE)