CHOP-CGTInformatics / REDCapTidieR

Makes it easy to read REDCap Projects into R
https://chop-cgtinformatics.github.io/REDCapTidieR/
Other
33 stars 8 forks source link

Improve `REDCapR` error messages #156

Closed ezraporter closed 1 year ago

ezraporter commented 1 year ago

Description

This PR improves error messages produced by try_redcapr() in 2 scenarios:

  1. The REDCapR operation returns with success == FALSE but doesn't error

In these cases we check for a few common error codes

https://github.com/CHOP-CGTInformatics/REDCapTidieR/blob/fe147b4e476c496f5ded1dfc54b4a66601ce53fc/R/utils.R#L641-L657

and otherwise issue a generic "unexpected error" message with our bug report link. This hides information REDCapR may have returned in outcome_message.

This PR includes the contents of outcome_message in the error. See screenshot 1.

  1. REDCapR returns success == FALSE due to a deleted project

This is the situation that instigated investigating scenario 1. I added an explicit check for this error message to the error code checks above.

Proposed Changes

Screenshots New unexpected error message: (Note that this won't actually ever appear because we added the explicit check for this case)

Screenshot 2023-06-01 at 3 19 59 PM

New deleted project error message:

Screenshot 2023-06-01 at 3 20 29 PM

PR Checklist

Before submitting this PR, please check and verify below that the submission meets the below criteria:

Code Review

This section to be used by the reviewer and developers during Code Review after PR submission

Code Review Checklist

rsh52 commented 1 year ago

Looks like the solution we want :+1:

Is there any way for us to force/trigger the deleted project response in a test? I think using str_detect() is fine here, but if for some reason Will/REDCapR were to change the message it feels a little fragile and it would be nice to easily identify a change like that.

https://github.com/CHOP-CGTInformatics/REDCapTidieR/blob/ba782a6d2c1cb22a1090a07742c270b28f010f85/R/utils.R#L659-L661

Can we also add these to the cli_message_examples.R file?