Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve wfs_api() error reporting #19

Open
jlehtoma opened this issue Aug 24, 2019 · 4 comments
Open

Improve wfs_api() error reporting #19

jlehtoma opened this issue Aug 24, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@jlehtoma
Copy link
Contributor

jlehtoma commented Aug 24, 2019

Currently wfs_api() passes the provided WFS URL as-is and expects a correct response. However, it is not robust against faulty URLs (404), timeouts (408) or any other unexpected situations. It would be good if it did. In principle this would be up to ows4R, but nut sure at this point how it deals with errors.

@jlehtoma jlehtoma self-assigned this Aug 24, 2019
@jlehtoma jlehtoma added the enhancement New feature or request label Aug 24, 2019
@jlehtoma jlehtoma added this to the 0.1 milestone Aug 24, 2019
@jlehtoma jlehtoma modified the milestones: 0.1, 1.0: First CRAN release Jan 20, 2020
@jlehtoma jlehtoma changed the title get_wfs_layer() does not handle errors well wfs_api() does not handle errors well Jan 20, 2020
@jlehtoma
Copy link
Contributor Author

Since we're not using ows4R, the checking responsibility is now on us (and maybe it was before too).

@jlehtoma jlehtoma changed the title wfs_api() does not handle errors well Improve wfs_api() error reporting Jan 20, 2020
@jlehtoma
Copy link
Contributor Author

@muuankarski we might be able to replace check_api_access() with little enhancements in wfs_api(). If you can figure out which HTTP status code you're receiving while behind company firewall / proxy, we could include warnings to the user here. Could you test what httr::GET() will give you (see here onwards) in case there's no access?

@muuankarski
Copy link
Collaborator

@jlehtoma

as we got access to geo.stat.fi from our servers yesterday, I will try to reach a layer in Paituli wfs.

# Desktop windows
httr::http_status(httr::GET("http://avaa.tdata.fi/geoserver/paituli/wfs?service=WFS&version=2.0.0&request=getFeature&typename=paituli:kotus_pitajaAll"))
Error in curl::curl_fetch_memory(url, handle = handle) : 
  Timeout was reached: [avaa.tdata.fi] Connection timed out after 10000 milliseconds```
# server
> httr::http_status(httr::GET("http://avaa.tdata.fi/geoserver/paituli/wfs?service=WFS&version=2.0.0&request=getFeature&typename=paituli:kotus_pitajaAll"))
$category
[1] "Client error"

$reason
[1] "Forbidden"

$message
[1] "Client error: (403) Forbidden"

So the problem with proxy requiring authentication is that you get no http status code from there. Therefore this download.file()-hack. But there must be more elegant way to address this?

@jlehtoma
Copy link
Contributor Author

Right! Thanks for checking this. I had a quick look at httr/curl and it seems that although it is possible to pass a custom failure callback to curl::curl_fetch_memory() used by httr::GET(), we can't actually pass such a callback through ``httr::GET()`. Two options come to mind:

  1. Do a separate probe with curl::curl_fetch_memory() (much like with download.file() now) within wfs_api() using a custom failure callback to let user know about potential issue with a proxy.
  2. Use tryCatch() with GET() within wfs_api(), catch timeout error (by parsing the error message) and let user know about potential issue with a proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants