Added support for API v3 error types on different error handlers

This commit is contained in:
Alejandro Celaya
2022-10-12 10:35:16 +02:00
parent d64abeecdc
commit e6c79c19c2
20 changed files with 92 additions and 47 deletions

View File

@@ -17,10 +17,10 @@ import {
ShlinkDomainRedirects,
ShlinkShortUrlsListParams,
ShlinkShortUrlsListNormalizedParams,
ProblemDetailsError,
} from '../types';
import { orderToString } from '../../utils/helpers/ordering';
import { isRegularNotFound } from '../utils';
import { isRegularNotFound, parseApiError } from '../utils';
import { ProblemDetailsError } from '../types/errors';
const buildShlinkBaseUrl = (url: string, version: 2 | 3) => `${url}/rest/v${version}`;
const rejectNilProps = reject(isNil);
@@ -129,7 +129,7 @@ export class ShlinkApiClient {
data: body,
paramsSerializer: { indexes: false },
}).catch((e: AxiosError<ProblemDetailsError>) => {
if (!isRegularNotFound(e.response?.data)) {
if (!isRegularNotFound(parseApiError(e))) {
throw e;
}