Supply deprecated req and res properties on IHttpFetchError for legacy compatibility (#48430) (#48555)

This commit is contained in:
Eli Perelman 2019-10-17 14:13:12 -05:00 committed by GitHub
parent 8ff906ac53
commit 8cc58a9866
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 0 deletions

View file

@ -16,6 +16,8 @@ export interface IHttpFetchError extends Error
| Property | Type | Description |
| --- | --- | --- |
| [body](./kibana-plugin-public.ihttpfetcherror.body.md) | <code>any</code> | |
| [req](./kibana-plugin-public.ihttpfetcherror.req.md) | <code>Request</code> | |
| [request](./kibana-plugin-public.ihttpfetcherror.request.md) | <code>Request</code> | |
| [res](./kibana-plugin-public.ihttpfetcherror.res.md) | <code>Response</code> | |
| [response](./kibana-plugin-public.ihttpfetcherror.response.md) | <code>Response</code> | |

View file

@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) &gt; [req](./kibana-plugin-public.ihttpfetcherror.req.md)
## IHttpFetchError.req property
> Warning: This API is now obsolete.
>
> Provided for legacy compatibility. Prefer the `request` property instead.
>
<b>Signature:</b>
```typescript
readonly req: Request;
```

View file

@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) &gt; [res](./kibana-plugin-public.ihttpfetcherror.res.md)
## IHttpFetchError.res property
> Warning: This API is now obsolete.
>
> Provided for legacy compatibility. Prefer the `response` property instead.
>
<b>Signature:</b>
```typescript
readonly res?: Response;
```

View file

@ -21,6 +21,9 @@ import { IHttpFetchError } from './types';
/** @internal */
export class HttpFetchError extends Error implements IHttpFetchError {
public readonly req: Request;
public readonly res?: Response;
constructor(
message: string,
public readonly request: Request,
@ -28,6 +31,8 @@ export class HttpFetchError extends Error implements IHttpFetchError {
public readonly body?: any
) {
super(message);
this.req = request;
this.res = response;
// captureStackTrace is only available in the V8 engine, so any browser using
// a different JS engine won't have access to this method.

View file

@ -236,6 +236,14 @@ export interface HttpResponse {
export interface IHttpFetchError extends Error {
readonly request: Request;
readonly response?: Response;
/**
* @deprecated Provided for legacy compatibility. Prefer the `request` property instead.
*/
readonly req: Request;
/**
* @deprecated Provided for legacy compatibility. Prefer the `response` property instead.
*/
readonly res?: Response;
readonly body?: any;
}

View file

@ -547,8 +547,12 @@ export type IContextProvider<THandler extends HandlerFunction<any>, TContextName
export interface IHttpFetchError extends Error {
// (undocumented)
readonly body?: any;
// @deprecated (undocumented)
readonly req: Request;
// (undocumented)
readonly request: Request;
// @deprecated (undocumented)
readonly res?: Response;
// (undocumented)
readonly response?: Response;
}