diff --git a/packages/runtime/test/transport/relationships.test.ts b/packages/runtime/test/transport/relationships.test.ts index d54d50287..aed15c564 100644 --- a/packages/runtime/test/transport/relationships.test.ts +++ b/packages/runtime/test/transport/relationships.test.ts @@ -174,7 +174,7 @@ describe("Can Create / Create Relationship", () => { expect(canCreateRelationshipResponse.isSuccess).toBe(false); expect(canCreateRelationshipResponse.message).toBe( - "The Identity who created the RelationshipTemplate is currently in the process of deleting itself. Thus, it is not possible to establish a Relationship to it." + "The Identity that created the RelationshipTemplate is currently in the process of deleting itself. Thus, it is not possible to establish a Relationship to it." ); expect(canCreateRelationshipResponse.code).toBe("error.transport.relationships.activeIdentityDeletionProcessOfOwnerOfRelationshipTemplate"); @@ -184,7 +184,7 @@ describe("Can Create / Create Relationship", () => { }); expect(createRelationshipResponse).toBeAnError( - "The Identity who created the RelationshipTemplate is currently in the process of deleting itself. Thus, it is not possible to establish a Relationship to it.", + "The Identity that created the RelationshipTemplate is currently in the process of deleting itself. Thus, it is not possible to establish a Relationship to it.", "error.transport.relationships.activeIdentityDeletionProcessOfOwnerOfRelationshipTemplate" ); }); diff --git a/packages/transport/src/core/TransportCoreErrors.ts b/packages/transport/src/core/TransportCoreErrors.ts index fdaa4be58..fcad454ad 100644 --- a/packages/transport/src/core/TransportCoreErrors.ts +++ b/packages/transport/src/core/TransportCoreErrors.ts @@ -42,10 +42,17 @@ class Relationships { return new CoreError("error.transport.relationships.reactivationAlreadyRequested", message); } + public deletedOwnerOfRelationshipTemplate() { + return new CoreError( + "error.transport.relationships.deletedOwnerOfRelationshipTemplate", + "The Identity that created the RelationshipTemplate has been deleted in the meantime. Thus, it is not possible to establish a Relationship to it." + ); + } + public activeIdentityDeletionProcessOfOwnerOfRelationshipTemplate() { return new CoreError( "error.transport.relationships.activeIdentityDeletionProcessOfOwnerOfRelationshipTemplate", - "The Identity who created the RelationshipTemplate is currently in the process of deleting itself. Thus, it is not possible to establish a Relationship to it." + "The Identity that created the RelationshipTemplate is currently in the process of deleting itself. Thus, it is not possible to establish a Relationship to it." ); } } diff --git a/packages/transport/src/modules/relationships/RelationshipsController.ts b/packages/transport/src/modules/relationships/RelationshipsController.ts index 2be070ded..53cfeee79 100644 --- a/packages/transport/src/modules/relationships/RelationshipsController.ts +++ b/packages/transport/src/modules/relationships/RelationshipsController.ts @@ -201,6 +201,10 @@ export class RelationshipsController extends TransportController { const result = await this.client.canCreateRelationship(peerAddress.toString()); + if (result.isError && result.error.code === "error.platform.recordNotFound" && result.error.message.includes("Identity not found.")) { + return Result.fail(TransportCoreErrors.relationships.deletedOwnerOfRelationshipTemplate()); + } + if (!result.value.canCreate) { if (result.value.code === "error.platform.validation.relationship.relationshipToTargetAlreadyExists") { return Result.fail(TransportCoreErrors.relationships.relationshipNotYetDecomposedByPeer()); diff --git a/packages/transport/test/modules/relationships/RelationshipsController.test.ts b/packages/transport/test/modules/relationships/RelationshipsController.test.ts index f6374444c..a4547bb55 100644 --- a/packages/transport/test/modules/relationships/RelationshipsController.test.ts +++ b/packages/transport/test/modules/relationships/RelationshipsController.test.ts @@ -120,15 +120,16 @@ describe("RelationshipsController", function () { await sender.syncEverything(); - await expect( - sender.relationships.canSendRelationship({ - template: loadedTemplate, - creationContent: { - mycontent: "request" - } - }) - ).rejects.toThrow( - "error.platform.recordNotFound (404): 'Identity not found. Make sure the ID exists and the record is not expired. If a password is required to fetch the record, make sure you passed the correct one.'" + const canSendRelationshipResult = await sender.relationships.canSendRelationship({ + template: loadedTemplate, + creationContent: { + mycontent: "request" + } + }); + expect(canSendRelationshipResult.isSuccess).toBe(false); + expect(canSendRelationshipResult.error.code).toBe("error.transport.relationships.deletedOwnerOfRelationshipTemplate"); + expect(canSendRelationshipResult.error.message).toContain( + "The Identity that created the RelationshipTemplate has been deleted in the meantime. Thus, it is not possible to establish a Relationship to it." ); await expect( @@ -138,9 +139,7 @@ describe("RelationshipsController", function () { mycontent: "request" } }) - ).rejects.toThrow( - "error.platform.recordNotFound (404): 'Identity not found. Make sure the ID exists and the record is not expired. If a password is required to fetch the record, make sure you passed the correct one.'" - ); + ).rejects.toThrow("error.transport.relationships.deletedOwnerOfRelationshipTemplate"); }); });