I realized that the server actually gives a more helpful error message in the body in the response, e.g. here
body:
encoding: UTF-8
file: no
string: '{"detail":"Invalid token."}'
in this case, the added value is not as obvious. a better example: i tried to get submissions for a survey but it didn't work because the asset was not deployed yet. the string then contained something like "the asset is not deployed yet" while the error raised by raise_for_status was just a 404 not found (or 400 invalid request, don't remember exactly).
not sure this is worth the effort though. alternatively, we could just check for the status code and then raise a simple usethis::ui_stop that combines the status code, the status message and the detailed "detail" message.
I realized that the server actually gives a more helpful error message in the body in the response, e.g. here
in this case, the added value is not as obvious. a better example: i tried to get submissions for a survey but it didn't work because the asset was not deployed yet. the string then contained something like "the asset is not deployed yet" while the error raised by
raise_for_statuswas just a 404 not found (or 400 invalid request, don't remember exactly).not sure this is worth the effort though. alternatively, we could just check for the status code and then raise a simple
usethis::ui_stopthat combines the status code, the status message and the detailed "detail" message.