Closed gothub closed 3 years ago
From slack:
metamattj 35 minutes ago
so, better to wrap the network call inside auth_get in a try block, and, if it fails, still return an appropriate error code
metamattj 34 minutes ago
that way calling code doesn’t have to worry about the network errors, and can assume the status code will be accurate
@gothub here is one approach: https://github.com/jeanetteclark/rdataone/commit/3952742c0c1a95998fa175538bb302705c041b43
I tested @jeanetteclark and your approach looks good to me.
Thanks @jeanetteclark - I tested both getDataPackage()
and getDataObject()
. The above code succeeds with the fix you made.
@gothub did you test on an object where you expect it to succeed right away? It just occurred to me I only tested on the failing case
@jeanetteclark good point - I just now checked used a data object that didn't have any network errors and that worked as well.
Closed from issue #266
@mbjones
The functions in
auth_request.R
:auth_get()
,auth_post()
, ... make calls to thehttr
package that can return network errors, for example, a run of the following script:returned this error:
This error was not handled by
getDataObject
, so caused the script to fail.Either wrap calls to the
auth*
functions or handle the errors internally in theauth*
functions.I would vote for wrapping the
auth*
functions in the calling routines, so that the calling routine can decide what action to take.What approach would be used if the errors are captured and handled internally to the
auth*
funcitons?