diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts index 57e76c427b9..037e0e4cfe4 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts @@ -168,13 +168,19 @@ export class PluginObjectStoreIpfs implements IPluginObjectStore { ex, ); } - } else if (ex instanceof Error) { - throw new RuntimeError(`unexpected exception`, ex); } else { - throw new RuntimeError( - "unexpected exception with incorrect type ", - JSON.stringify(ex), - ); + if ( + (ex as any).stack?.includes(K_IPFS_JS_HTTP_ERROR_FILE_DOES_NOT_EXIST) + ) { + const msg = `Stat ${req.key} failed with error message containing phrase "${K_IPFS_JS_HTTP_ERROR_FILE_DOES_NOT_EXIST}" Returning isPresent=false ...`; + this.log.debug(msg); + return { key: req.key, checkedAt, isPresent: false }; + } else { + throw new RuntimeError( + `Checking presence of ${req.key} crashed:`, + JSON.stringify(ex), + ); + } } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts index 69d999ff993..226346fff81 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts @@ -27,7 +27,7 @@ import { GetKeychainEntryEndpointV1 } from "./web-services/get-keychain-entry-en import { SetKeychainEntryEndpointV1 } from "./web-services/set-keychain-entry-endpoint-v1"; import { HasKeychainEntryEndpointV1 } from "./web-services/has-keychain-entry-endpoint-v1"; import { DeleteKeychainEntryEndpointV1 } from "./web-services/delete-keychain-entry-endpoint-v1"; -import axios from "axios"; + export interface IPluginKeychainVaultOptions extends ICactusPluginOptions { logLevel?: LogLevelDesc; keychainId: string; @@ -232,12 +232,8 @@ export class PluginKeychainVault implements IPluginWebService, IPluginKeychain { if ((ex as any).response?.statusCode === HttpStatus.NOT_FOUND) { return (null as unknown) as string; } else { - if ((ex as any).response?.status === HttpStatus.NOT_FOUND) { - return (null as unknown) as string; - } else { - this.log.error(`Retrieval of "${key}" crashed:`, ex); - throw ex; - } + this.log.error(`Retrieval of "${key}" crashed:`, ex); + throw ex; } } } @@ -263,12 +259,8 @@ export class PluginKeychainVault implements IPluginWebService, IPluginKeychain { if ((ex as any).response?.statusCode === HttpStatus.NOT_FOUND) { return false; } else { - if ((ex as any).response?.status === HttpStatus.NOT_FOUND) { - return false; - } else { - this.log.error(`Presence check of "${key}" crashed:`, ex); - throw ex; - } + this.log.error(`Presence check of "${key}" crashed:`, ex); + throw ex; } } } diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/initialize-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/initialize-endpoint-invalid.test.ts index 61e867073b8..44429f32647 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/initialize-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/initialize-endpoint-invalid.test.ts @@ -29,7 +29,6 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory import { DataTest } from "../data-test"; import DemoHelperJSON from "../../../solidity/contracts/DemoHelpers.json"; import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/main/solidity/contracts/HashTimeLock.json"; -import axios from "axios"; const connectorId = uuidv4(); const logLevel: LogLevelDesc = "INFO";