ropensci / comtradr

Functions for Interacting with the UN Comtrade API
https://docs.ropensci.org/comtradr
64 stars 17 forks source link

Modify API error msg to be more clear #8

Closed ChrisMuir closed 6 years ago

ChrisMuir commented 6 years ago

Here is an example:

vals <- ct_search(reporters = "Canada",
                  partners = "Germany",
                  type = "services")
#> Error: API request failed, with status code [200]
#> Fail Reason: Invalid classification for trade type.

This error message is related to an invalid input for arg type, and has nothing to do with request status codes. I think it makes sense to remove the references to status codes in error messages when the failure had nothing to do with the status code, and the status code is 200.

This issue first came up in #5

ChrisMuir commented 6 years ago

Error messages that are related to invalid input args (and are NOT related to status codes) now look like this:

ct_search(reporters = "Canada",
          partners = "Germany",
          trade_direction = "all",
          commod_codes = "invalid_codes")
#> Error: API request failed. Err msg from Comtrade:
#>   invalid_codes is an invalid commodity code.