Fix parsing of Retry-After
This commit is contained in:
parent
6dfef6e70d
commit
fa3937e084
2 changed files with 6 additions and 6 deletions
|
@ -16,5 +16,9 @@ export function findRetryAfterTimeFromError(err: unknown): number {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(rawValue)) {
|
||||||
|
return parseRetryAfterWithDefault(rawValue[0]);
|
||||||
|
}
|
||||||
|
|
||||||
return parseRetryAfterWithDefault(rawValue);
|
return parseRetryAfterWithDefault(rawValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,12 @@ function appendStack(newError: Error, originalError: Error) {
|
||||||
newError.stack += `\nOriginal stack:\n${originalError.stack}`;
|
newError.stack += `\nOriginal stack:\n${originalError.stack}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HTTPErrorHeadersType = {
|
|
||||||
[name: string]: string | ReadonlyArray<string>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class HTTPError extends Error {
|
export class HTTPError extends Error {
|
||||||
public override readonly name = 'HTTPError';
|
public override readonly name = 'HTTPError';
|
||||||
|
|
||||||
public readonly code: number;
|
public readonly code: number;
|
||||||
|
|
||||||
public readonly responseHeaders: HTTPErrorHeadersType;
|
public readonly responseHeaders: HeaderListType;
|
||||||
|
|
||||||
public readonly response: unknown;
|
public readonly response: unknown;
|
||||||
|
|
||||||
|
@ -33,7 +29,7 @@ export class HTTPError extends Error {
|
||||||
message: string,
|
message: string,
|
||||||
options: {
|
options: {
|
||||||
code: number;
|
code: number;
|
||||||
headers: HTTPErrorHeadersType;
|
headers: HeaderListType;
|
||||||
response?: unknown;
|
response?: unknown;
|
||||||
stack?: string;
|
stack?: string;
|
||||||
cause?: unknown;
|
cause?: unknown;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue