From 15d272057f07a62a08f86827ad70f682e2cb1e71 Mon Sep 17 00:00:00 2001 From: Stephen Smith Date: Tue, 12 Nov 2024 10:09:13 -0500 Subject: [PATCH] 22000: Add common resource error checker for 404 Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- .../src/services/common-service/common-resource-service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/workbench2/src/services/common-service/common-resource-service.ts b/services/workbench2/src/services/common-service/common-resource-service.ts index 6d95e8e818..20ad9867ec 100644 --- a/services/workbench2/src/services/common-service/common-resource-service.ts +++ b/services/workbench2/src/services/common-service/common-resource-service.ts @@ -13,6 +13,7 @@ export enum CommonResourceServiceError { OWNERSHIP_CYCLE = 'OwnershipCycle', MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState', NAME_HAS_ALREADY_BEEN_TAKEN = 'NameHasAlreadyBeenTaken', + NOT_FOUND = 'NotFound', PERMISSION_ERROR_FORBIDDEN = 'PermissionErrorForbidden', SOURCE_DESTINATION_CANNOT_BE_SAME = 'SourceDestinationCannotBeSame', UNKNOWN = 'Unknown', @@ -62,6 +63,7 @@ export class CommonResourceService extends CommonService export const getCommonResourceServiceError = (errorResponse: any) => { if (errorResponse && 'errors' in errorResponse) { const error = errorResponse.errors.join(''); + const status = errorResponse.status; switch (true) { case /UniqueViolation/.test(error): return CommonResourceServiceError.UNIQUE_NAME_VIOLATION; @@ -71,6 +73,8 @@ export const getCommonResourceServiceError = (errorResponse: any) => { return CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE; case /Name has already been taken/.test(error): return CommonResourceServiceError.NAME_HAS_ALREADY_BEEN_TAKEN; + case status === 404: + return CommonResourceServiceError.NOT_FOUND; case /403 Forbidden/.test(error): return CommonResourceServiceError.PERMISSION_ERROR_FORBIDDEN; case new RegExp(CommonResourceServiceError.SOURCE_DESTINATION_CANNOT_BE_SAME).test(error): -- 2.30.2