diff --git a/src/relayer-provider/v1/networkV1.ts b/src/relayer-provider/v1/networkV1.ts index 1904db1b..ca47536d 100644 --- a/src/relayer-provider/v1/networkV1.ts +++ b/src/relayer-provider/v1/networkV1.ts @@ -11,6 +11,7 @@ import { } from '@sdk/lowlevel/constants'; import { fetchRelayerV1Get } from './fetchRelayerV1'; import { isNonEmptyString, removeSuffix } from '@base/string'; +import { TFHEError } from '../../errors/TFHEError'; // eslint-disable-next-line @typescript-eslint/consistent-type-definitions type CachedKey = { @@ -142,7 +143,8 @@ export async function getKeysFromRelayer( keyurlCache[versionUrl] = result; return result; } catch (e) { - throw new Error('Impossible to fetch public key: wrong relayer url.', { + throw new TFHEError({ + message: 'Failed to fetch keys from relayer', cause: e, }); } diff --git a/src/sdk/lowlevel/TFHEPkeCrs.test.ts b/src/sdk/lowlevel/TFHEPkeCrs.test.ts index e4c2bd14..4e9ba8a6 100644 --- a/src/sdk/lowlevel/TFHEPkeCrs.test.ts +++ b/src/sdk/lowlevel/TFHEPkeCrs.test.ts @@ -270,19 +270,19 @@ describeIfFetchMock('TFHEPkeCrs', () => { it('throws on invalid params (missing id)', async () => { await expect( TFHEPkeCrs.fetch({ srcUrl: testUrl, capacity: 2048 } as any), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch CRS'); }); it('throws on invalid params (missing srcUrl)', async () => { await expect( TFHEPkeCrs.fetch({ id: assetPublicParamsId, capacity: 2048 } as any), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch CRS'); }); it('throws on invalid params (missing capacity)', async () => { await expect( TFHEPkeCrs.fetch({ id: assetPublicParamsId, srcUrl: testUrl } as any), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch CRS'); }); it('throws on fetch error', async () => { diff --git a/src/sdk/lowlevel/TFHEPkeCrs.ts b/src/sdk/lowlevel/TFHEPkeCrs.ts index 0fd0cb95..d2fd8b5b 100644 --- a/src/sdk/lowlevel/TFHEPkeCrs.ts +++ b/src/sdk/lowlevel/TFHEPkeCrs.ts @@ -172,7 +172,7 @@ export class TFHEPkeCrs { return await TFHEPkeCrs.#fetch(params); } catch (e) { throw new TFHEError({ - message: 'Impossible to fetch public key: wrong relayer url.', + message: 'Failed to fetch CRS', cause: e, }); } diff --git a/src/sdk/lowlevel/TFHEPkeParams.test.ts b/src/sdk/lowlevel/TFHEPkeParams.test.ts index 1ea83916..e29c978d 100644 --- a/src/sdk/lowlevel/TFHEPkeParams.test.ts +++ b/src/sdk/lowlevel/TFHEPkeParams.test.ts @@ -309,7 +309,7 @@ describe('TFHEPkeParams', () => { capacity: 2048, }, }), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch PKE params'); }); it('throws on invalid pkeCrs bytes', async () => { @@ -334,7 +334,7 @@ describe('TFHEPkeParams', () => { capacity: 2048, }, }), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch PKE params'); }); }); }); diff --git a/src/sdk/lowlevel/TFHEPkeParams.ts b/src/sdk/lowlevel/TFHEPkeParams.ts index 101d730e..c1e7e876 100644 --- a/src/sdk/lowlevel/TFHEPkeParams.ts +++ b/src/sdk/lowlevel/TFHEPkeParams.ts @@ -166,7 +166,7 @@ export class TFHEPkeParams { }); } catch (e) { throw new TFHEError({ - message: 'Impossible to fetch public key: wrong relayer url.', + message: 'Failed to fetch PKE params', cause: e, }); } diff --git a/src/sdk/lowlevel/TFHEPublicKey.test.ts b/src/sdk/lowlevel/TFHEPublicKey.test.ts index 3c0b44d6..8e934bf8 100644 --- a/src/sdk/lowlevel/TFHEPublicKey.test.ts +++ b/src/sdk/lowlevel/TFHEPublicKey.test.ts @@ -285,13 +285,13 @@ describe('TFHEPublicKey', () => { it('throws on invalid params (missing id)', async () => { await expect( TFHEPublicKey.fetch({ srcUrl: testUrl } as any), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch public key'); }); it('throws on invalid params (missing srcUrl)', async () => { await expect( TFHEPublicKey.fetch({ id: tfhePublicKeyBytes.id } as any), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch public key'); }); it('throws on fetch error', async () => { @@ -318,7 +318,7 @@ describe('TFHEPublicKey', () => { id: tfhePublicKeyBytes.id, srcUrl: testUrl, }), - ).rejects.toThrow('Impossible to fetch public key: wrong relayer url.'); + ).rejects.toThrow('Failed to fetch public key'); }); }); diff --git a/src/sdk/lowlevel/TFHEPublicKey.ts b/src/sdk/lowlevel/TFHEPublicKey.ts index e60ef1a6..e1c5a6dc 100644 --- a/src/sdk/lowlevel/TFHEPublicKey.ts +++ b/src/sdk/lowlevel/TFHEPublicKey.ts @@ -129,7 +129,7 @@ export class TFHEPublicKey { return await TFHEPublicKey.#fetch(params); } catch (e) { throw new TFHEError({ - message: 'Impossible to fetch public key: wrong relayer url.', + message: 'Failed to fetch public key', cause: e, }); }