diff --git a/lib/specifications/types/Application.js b/lib/specifications/types/Application.js index f153e5176..05303eb92 100644 --- a/lib/specifications/types/Application.js +++ b/lib/specifications/types/Application.js @@ -214,11 +214,16 @@ class Application extends ComponentProject { return this._pManifests[filePath] = this._getRawSourceReader().byPath(filePath) .then(async (resource) => { if (!resource) { - throw new Error( + const error = new Error( `Could not find resource ${filePath} in project ${this.getName()}`); + error.code = "ENOENT"; // "File or directory does not exist" + throw error; } return JSON.parse(await resource.getString()); }).catch((err) => { + if (err.code === "ENOENT") { + throw err; + } throw new Error( `Failed to read ${filePath} for project ` + `${this.getName()}: ${err.message}`); diff --git a/test/lib/specifications/types/Application.js b/test/lib/specifications/types/Application.js index 19b9054a3..38699c4a3 100644 --- a/test/lib/specifications/types/Application.js +++ b/test/lib/specifications/types/Application.js @@ -583,10 +583,10 @@ test.serial("_getManifest: File does not exist", async (t) => { const project = await Specification.create(projectInput); const error = await t.throwsAsync(project._getManifest("/does-not-exist.json")); - t.deepEqual(error.message, - "Failed to read /does-not-exist.json for project application.a: " + + t.is(error.message, "Could not find resource /does-not-exist.json in project application.a", "Rejected with correct error message"); + t.is(error.code, "ENOENT"); }); test.serial("_getManifest: result is cached", async (t) => {