got 14.1.0 → 14.2.1
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.
|
@@ -3,7 +3,7 @@ import is from '@sindresorhus/is';
|
|
|
3
3
|
import PCancelable from 'p-cancelable';
|
|
4
4
|
import { HTTPError, RetryError, } from '../core/errors.js';
|
|
5
5
|
import Request from '../core/index.js';
|
|
6
|
-
import { parseBody, isResponseOk } from '../core/response.js';
|
|
6
|
+
import { parseBody, isResponseOk, ParseError } from '../core/response.js';
|
|
7
7
|
import proxyEvents from '../core/utils/proxy-events.js';
|
|
8
8
|
import { CancelError } from './types.js';
|
|
9
9
|
const proxiedRequestEvents = [
|
|
@@ -49,7 +49,13 @@ export default function asPromise(firstRequest) {
|
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
51
51
|
// Fall back to `utf8`
|
|
52
|
-
|
|
52
|
+
try {
|
|
53
|
+
response.body = response.rawBody.toString();
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
request._beforeError(new ParseError(error, response));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
53
59
|
if (isResponseOk(response)) {
|
|
54
60
|
request._beforeError(error);
|
|
55
61
|
return;
|
|
@@ -15,7 +15,7 @@ export class RequestError extends Error {
|
|
|
15
15
|
request;
|
|
16
16
|
timings;
|
|
17
17
|
constructor(message, error, self) {
|
|
18
|
-
super(message);
|
|
18
|
+
super(message, { cause: error });
|
|
19
19
|
Error.captureStackTrace(this, this.constructor);
|
|
20
20
|
this.name = 'RequestError';
|
|
21
21
|
this.code = error.code ?? 'ERR_GOT_REQUEST_ERROR';
|