apify-client 3.0.0-beta.18 → 3.0.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apify_api_error.js +6 -4
- package/dist/bundle.js +9 -9
- package/dist/bundle.js.map +1 -1
- package/dist/http_client.js +7 -0
- package/package.json +1 -1
package/dist/apify_api_error.js
CHANGED
|
@@ -70,14 +70,16 @@ export class ApifyApiError extends Error {
|
|
|
70
70
|
let type;
|
|
71
71
|
let responseData = response.data;
|
|
72
72
|
let errorData;
|
|
73
|
-
//
|
|
74
|
-
//
|
|
73
|
+
// A `forceBuffer` request (e.g. `downloadItems()`) and a failed streaming request, whose body `HttpClient`
|
|
74
|
+
// has read into a buffer, both arrive unparsed. Parse the body here to get at the error.
|
|
75
75
|
if (isBuffer(responseData)) {
|
|
76
|
+
const body = isomorphicBufferToString(response.data, 'utf-8');
|
|
76
77
|
try {
|
|
77
|
-
responseData = JSON.parse(
|
|
78
|
+
responseData = JSON.parse(body);
|
|
78
79
|
}
|
|
79
80
|
catch {
|
|
80
|
-
//
|
|
81
|
+
// A body that is not JSON at all, such as an HTML error page from a proxy, is kept as text.
|
|
82
|
+
responseData = body;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
if (responseData && responseData.error) {
|