-
Notifications
You must be signed in to change notification settings - Fork 12
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
Inconsistent return types in package functions #37
Comments
It is definitely much nicer to get an object! It would be better for all functions return the API response object (the user) directly on success. For POST or PUT requests, it would at least return the input given to the function (formId) if the API does not return anything in the tidyverse manner. BUT it would be cleaner to handle errors of all functions in a consistent manner so that all the package functions act in a similar way and give the user/coder a single way to handle any number of error types. On error, I would propose to simply throw the error condition on failure. This can work across all types of functions regardless of whether they are get, post, put and regardless of the nature of the error. In the case of Logging of error conditions and a tryCatch/tryCatchLog type construction should enable you to do any error handling required and check the status of each error if necessary and inspect the error object. |
@nickdickinson can this be closed? |
The intention was to keep a list of all the R package functions that don't use the standard pattern of providing the same response as the server and throwing an error when there is an API error. This is still the case with addDatabaseUser(). They mostly also do not use the rest.R functions to talk to the API as well, which means they will not support errors in the same way and will need to be maintained separately. |
|
At the moment, there are few functions that are not behaving the same as others. When there is an error, they do not return an error but rather a specially formatted object or a NULL. This makes it difficult to have a consistent and predictable pattern for each function call in the package and may also confuse users. I'm opening this issue to be able to document these in one place and so we can discuss.
As I am writing tests for the package functions, I've noted two so far:
Ideas:
The text was updated successfully, but these errors were encountered: