Skip to content

Upload API throws RuntimeException #44

Open

Description

@JulienArzul

Hello,

You should provide an easy way to handle upload errors in your SDK.

The method signature suggests that you will be throwing an IOException but looking at the source code, we can see that you're actually throwing RuntimeException in several cases ! These cases should be handled differently in the SDK so that the caller can identify them : they are definitely not a reason to throw a RuntimeException.

At the minimum, you should throw a IOException as specified by the upload signature.
Alternatively, you could think about a nicer error handling system, either with a custom Exception or with a specific Map returned (whose values should be documented !).

Activity

  1. tocker commented on May 18, 2016

    @tocker
    Contributor

    Hi @JulienArzul,
    You may have a point here however we cannot change the exception to IOException without changing the method signature and thus breaking backward compatibility.
    We'll revisit this issue on the next major version release.

  2. self-assigned this
    on May 18, 2016
  3. rocketraman commented on Jun 2, 2016

    @rocketraman

    +1

    You may have a point here however we cannot change the exception to IOException without changing the method signature and thus breaking backward compatibility.

    Actually you can change it without changing the signature -- the method already declares throws IOException. It just doesn't.

    However, I'd note @JulienArzul's other comment: better to use a custom exception type that allows extracting the status code and a Map that contains the body of the response, or some structured type with the same values.

  4. removed their assignment
    on Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions