-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve errors #211
Improve errors #211
Conversation
Renamed `TransloaditError` to `ApiError`. Differences between `TransloaditError` and `ApiError`: - Moved `TransloaditError.response.body` to `ApiError.response` - Removed `TransloaditError.assemblyId` (can now be found in `ApiError.response.assembly_id` - Removed `TransloaditError.transloaditErrorCode` (can now be found in `ApiError.response.error` - `ApiError` does not inherit from `got.HTTPError`, but `ApiError.cause` will be the `got.HTTPError` instance that caused this error (except for when Tranloadit API responds with HTTP 200 and `error` prop set in JSON response, in which case cause will be `undefined`). Note that (just like before) when the Transloadit API responds with an error we will always throw a `ApiError` - In all other cases (like request timeout, connection error, TypeError etc.), we don't wrap the error in `ApiError`. Also improved error stack traces, added a unit test in `mock-http.test.ts` that verifies the stack trace.
...of #211 where `ApiError` has all the API response properties directly on it instaed of inside a `response` object - `ApiError.response.error` -> `ApiError.code` - `ApiError.response.message` -> `ApiError.rawMessage` - `ApiError.response.assembly_id` -> `ApiError.assemblyId` - `ApiError.response.assembly_ssl_url` -> `ApiError.assemblySslUrl`
I suggest we go with #212 instead. |
I agree with all your suggestions. I've added them to the other PR #212 |
doesn't really matter i think |
if we merge #212, this PR will contain that pr's commits too |
* make alternative implementation ...of #211 where `ApiError` has all the API response properties directly on it instaed of inside a `response` object - `ApiError.response.error` -> `ApiError.code` - `ApiError.response.message` -> `ApiError.rawMessage` - `ApiError.response.assembly_id` -> `ApiError.assemblyId` - `ApiError.response.assembly_ssl_url` -> `ApiError.assemblySslUrl` * fix formatting * Update README.md Co-authored-by: Remco Haszing <[email protected]> * remove stack hack #211 (comment) * improve assertion * fix typo * fix formatting --------- Co-authored-by: Remco Haszing <[email protected]>
Alright! Closing in favor of #212 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #211 +/- ##
==========================================
- Coverage 69.60% 68.36% -1.25%
==========================================
Files 6 6
Lines 612 588 -24
Branches 121 113 -8
==========================================
- Hits 426 402 -24
Misses 186 186
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
oops what i meant is that yes both PRs need to be merged but the order doesn't matter |
i assume your intention was to merge this PR also then, so i'll do that now :) |
Renamed
TransloaditError
toApiError
. Differences betweenTransloaditError
andApiError
:TransloaditError.response.body
toApiError.response
TransloaditError.assemblyId
(can now be found inApiError.response.assembly_id
TransloaditError.transloaditErrorCode
(can now be found inApiError.response.error
ApiError
does not inherit fromgot.HTTPError
, butApiError.cause
will be thegot.HTTPError
instance that caused this error (except for when Tranloadit API responds with HTTP 200 anderror
prop set in JSON response, in which case cause will beundefined
).Note that (just like before) when the Transloadit API responds with an error we will always throw a
ApiError
- In all other cases (like request timeout, connection error, TypeError etc.), we don't wrap the error inApiError
.Also improved error stack traces, added a unit test in
mock-http.test.ts
that verifies the stack trace.See which implementation you like more, this or #212
closes #154