diff --git a/index.js b/index.js index d1a082e..ea0b3a5 100644 --- a/index.js +++ b/index.js @@ -98,7 +98,9 @@ class RefResolver { const targetSchema = this.getDerefSchema(refSchemaId, refJsonPointer) if (targetSchema === null) { - throw new Error(`Cannot resolve ref "${ref.ref}".`) + throw new Error( + `Cannot resolve ref "${ref.ref}". Ref ${refJsonPointer} is not found in schema "${refSchemaId}".` + ) } ref.targetSchema = targetSchema diff --git a/test/deref-schema.test.js b/test/deref-schema.test.js index d0b196b..8d35d7b 100644 --- a/test/deref-schema.test.js +++ b/test/deref-schema.test.js @@ -228,6 +228,9 @@ test('should throw if target ref schema is not found', () => { try { refResolver.derefSchema('relativeAddress') } catch (error) { - assert.strictEqual(error.message, 'Cannot resolve ref "#foo".') + assert.strictEqual( + error.message, + 'Cannot resolve ref "#foo". Ref #foo is not found in schema "relativeAddress".' + ) } })