Better types for WebAPI

This commit is contained in:
Fedor Indutny 2021-09-21 17:58:03 -07:00 committed by GitHub
parent c05d23e628
commit b9d6497cb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 156 additions and 107 deletions

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import * as log from '../logging/log';
import { HTTPError } from './Errors';
export async function handleStatusCode(status: number): Promise<void> {
if (status === 499) {
@ -11,7 +12,7 @@ export async function handleStatusCode(status: number): Promise<void> {
}
}
export function translateError(error: Error): Error | undefined {
export function translateError(error: HTTPError): HTTPError | undefined {
const { code } = error;
if (code === 200) {
// Happens sometimes when we get no response. Might be nice to get 204 instead.