Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 4x 4x 4x 6x 6x 6x 6x 6x 4x 4x 2x 2x 2x 4x | const NETWORK_ERROR_CODE = 'network_error';
const NETWORK_ERROR_MESSAGE = 'A network error has occurred. Please retry';
/**
* Connector used by the authentication client to connect to a server
*/
export interface FetchConnector {
/**
* Creates an accessToken
*/
createAccessToken(
fetchOptions: RequestInit
): Promise<{ accessToken: string }>;
/**
* Logouts the user by removing the refreshToken
*/
logout(fetchOptions: RequestInit): Promise<{ done: boolean }>;
}
/**
* A fetch returns an error
*/
export class FetchError extends Error {
public res: Response;
public status: number;
public code: string | number;
constructor(
res: Response,
data?: { message?: string; code?: string | number }
) {
super((data && data.message) || res.statusText);
this.name = 'FetchError';
this.status = res.status;
this.code = (data && data.code) || res.status;
this.res = res;
}
}
/**
* A fetch fails
*/
export class NetworkError extends Error {
public code: string;
constructor() {
super(NETWORK_ERROR_MESSAGE);
this.name = 'NetworkError';
this.code = NETWORK_ERROR_CODE;
}
}
|