Improved handling of short URL deletion errors

This commit is contained in:
Alejandro Celaya
2020-12-21 21:02:30 +01:00
parent 54b1ab12cd
commit f69f791790
2 changed files with 15 additions and 11 deletions

View File

@@ -77,10 +77,18 @@ export interface ProblemDetailsError {
[extraProps: string]: any;
}
export interface InvalidArgumentError extends ProblemDetailsError {
interface InvalidArgumentError extends ProblemDetailsError {
type: 'INVALID_ARGUMENT';
invalidElements: string[];
}
interface InvalidShortUrlDeletion extends ProblemDetailsError {
type: 'INVALID_SHORTCODE_DELETION';
threshold?: number;
}
export const isInvalidArgumentError = (error?: ProblemDetailsError): error is InvalidArgumentError =>
error?.type === 'INVALID_ARGUMENT';
export const isInvalidDeletionError = (error?: ProblemDetailsError): error is InvalidShortUrlDeletion =>
error?.type === 'INVALID_SHORTCODE_DELETION';