feat: improve BBMRI negotiator error handling and do some cleanup #215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important: I couldn't fully test this because I'm not whitelisted to send requests to the BBMRI Negotiator.
I set out to improve the error handling and ended up rewriting the entire file. Improvements include:
errorChannel
instead ofalert()
to inform the user of errorsnegotiateOptions
(previously incorrectlynegotiatorOptions
) so that types are correctly inferredI've decided to use the same user-facing error message for all types of errors: "Fehler beim Anfragen der Daten und Proben". My take is that describing in more detail what went wrong (e.g. network error or unexpected HTTP status code) wouldn't really provide any benefit to the user who couldn't take action anyways. So this potentially fixes #210 even though it doesn't do exactly what is described there because I don't think it's a good idea. Do you agree in general with this approach or do you prefer more specific user-facing errors?