Commit a8a9b01
Konstantinos Bairaktaris
Refactor transifex.api's exceptions for down/uploads
Previously, for uploads and downloads we could get a "successful"
response that includes an error report for a download or upload. This
means that as far as {json:api} semantics go, no error has happened.
However, we intercepted this response and raised it as if it was a
{json:api} exception.
This raising was buggy because it didn't use the `JsonApiException.new`
invocation (and thus can't be captured with `JsonApiException.get`) and
also it didn't have the third required argument which was the response.
Instead of fixing the aforementioned bugs however, we decided to
implement new exception classes in `transifex.api` (which is the SDK
itself, as opposed to `transifex.api.jsonapi` which is the "SDK
library"). This makes it clearer to the user that as far as the
{json:api} semantics are concerned, no error has occured. The problem is
that the download or upload "job"'s status (which was successfully
retrieved) is reporting an error.
The new exception classes give priority to their first argument which is
the 'detail' field of the first error included in the response. The rest
of the errors, if any, will be accessible from the exception's second
argument. Keep in mind that at the time of writing, Transifex APIv3 will
only include one error in the case of an unsuccessful upload or
download.1 parent 5fd1f97 commit a8a9b01
2 files changed
Lines changed: 46 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
32 | 27 | | |
33 | 28 | | |
34 | 29 | | |
| |||
54 | 49 | | |
55 | 50 | | |
56 | 51 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
67 | 57 | | |
68 | 58 | | |
69 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments