Skip to content

Fail gracefully on internet access failure #104

@deepayan

Description

@deepayan

nhanes() fails gracefully when internet is unavailable, but not all other functions do:

> nhanes('AUX_D')
Data set  AUX_D  is not available
NULL
> nhanesCodebook('AUX_D')
URL https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2005/DataFiles/AUX_D.htm does not seem to exist
URL https://wwwn.cdc.gov/Nchs/Nhanes/limited_access/AUX_D.htm does not seem to exist
Error in nhanesCodebook("AUX_D") : could not find a web page for AUX_D
> nhanesTableSummary('DEMO_D', use = "codebook")
URL https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2005/DataFiles/DEMO_D.htm does not seem to exist
URL https://wwwn.cdc.gov/Nchs/Nhanes/limited_access/DEMO_D.htm does not seem to exist
Error in nhanesCodebook(nh_table, ...) : 
  could not find a web page for DEMO_D
> nhanesDXA(2001)
Error in curlGetHeaders(url) : libcurl error code 6:
	Could not resolve host: wwwn.cdc.gov
> nhanesFromURL("https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2007/DataFiles/VIX_E.xpt")
Error in curlGetHeaders(url) : libcurl error code 6:
	Could not resolve host: wwwn.cdc.gov
> nhanesTranslate('DEMO_B', c('DMDBORN','DMDCITZN'))
URL https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2001/DataFiles/DEMO_B.htm does not seem to exist
Error in UseMethod("xml_find_all") : 
  no applicable method for 'xml_find_all' applied to an object of class "NULL"

For now, I will put these examples inside try(), but we should review and fix these if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions