uploadcare / uploadcare-ruby

Ruby API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
MIT License
39 stars 28 forks source link

When polling, raise if an error is returned #142

Closed geeosh closed 11 months ago

geeosh commented 1 year ago

Previously, if an error from the API was returned while polling for updates on a file, it would continue polling. I updated the gem so that it raises a RequestError if the API returns an error status. If not, it raises a RetryError, which is swallowed by the retry gem's with_retries block.

Reproduction Steps

  1. Call Uploadcare::Uploader.upload(file_url) with a file type that Uploadcare says isn't supported (oddly the mimetype on a file I get this message with is audio/mpeg, which should be supported).
  2. There will be no output from the console while the gem continues to poll from_url/status/, which returns an error, such as:
    {"status":"error","error":"File validation error: Uploading of these file types is not allowed.","error_code":"DownloadFileValidationFailedError"}
kraft001 commented 1 year ago

Hey, @geeosh ! Thank you for the contribution, the update looks great to me! It would be nice to add a spec to test the new feature

geeosh commented 11 months ago

@kraft001 sure thing, I can submit an update for this later this week.