uploadcare / uploadcare-java

Java API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
Apache License 2.0
6 stars 13 forks source link

Error reporting enhancements #4

Closed dnavre closed 9 years ago

dnavre commented 9 years ago

As I understand it most of your REST API calls should return status code 200. If they don't do that that means that there was an error.

Currently I'm trying to save an uploaded resource to a custom storage configured in my uploadcare account. The call fails but I've got no way of finding out why cause I've got no access to the underlying HTTP Response and can't possibly find out what I got instead of the expected response. The client also ain't throwing any exceptions.

I think the RequestHelper needs to be configured to return the HTTP Responses and checks should be added to detect errors produced by the API to throw exceptions.

I can implement most of this myself but I need to know that you guys agree with me and are going to work with me on this. It would be also good to merge my changes to the master branch and make the newer version available in maven central.

dmitry-mukhin commented 9 years ago

copying should return 201 when in doubt, you can look at python lib, it's more up-to-date and feature complete. https://github.com/uploadcare/pyuploadcare/blob/39ab2eb9b5e3b0d9d12824307719c8ff8dcded77/pyuploadcare/api.py#L151-L176

dnavre commented 9 years ago

I can't check the response code in the current implementation cause the current implementation of the RequestHelper ain't returning the HTTP Response. It processes it internally and only returns the body of the response. So I get an empty body and no idea why the call failed.

Should I refactor the RequestHelper for it to return the full HTTP Response object?

dmitry-mukhin commented 9 years ago

sure, if you're up to it. also, please take a look at #2

dnavre commented 9 years ago

I've implemented the changes spoke of at a basic level. Please see pull request https://github.com/uploadcare/uploadcare-java/pull/5

dmitry-mukhin commented 9 years ago

implemented in #5