2020-12-21 23:51:35 +01:00
|
|
|
import { AxiosError } from 'axios';
|
2020-12-22 09:49:13 +01:00
|
|
|
import { InvalidArgumentError, InvalidShortUrlDeletion, ProblemDetailsError } from '../types';
|
2020-12-21 23:51:35 +01:00
|
|
|
|
|
|
|
export const parseApiError = (e: AxiosError<ProblemDetailsError>) => e.response?.data;
|
2020-12-22 09:49:13 +01:00
|
|
|
|
|
|
|
export const isInvalidArgumentError = (error?: ProblemDetailsError): error is InvalidArgumentError =>
|
|
|
|
error?.type === 'INVALID_ARGUMENT';
|
|
|
|
|
|
|
|
export const isInvalidDeletionError = (error?: ProblemDetailsError): error is InvalidShortUrlDeletion =>
|
2022-01-25 19:51:08 +01:00
|
|
|
error?.type === 'INVALID_SHORTCODE_DELETION' || error?.type === 'INVALID_SHORT_URL_DELETION';
|