From 92ccaf80a2108a53ebdb463f5094bec131f4b0e8 Mon Sep 17 00:00:00 2001 From: Viktor Skarlatov Date: Wed, 11 May 2016 13:47:48 +0300 Subject: [PATCH 1/2] Added a more descriptive error message in the app boostrap. --- src/src/com/tns/Module.java | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/src/com/tns/Module.java b/src/src/com/tns/Module.java index 39f13a633..36d70c5b5 100644 --- a/src/src/com/tns/Module.java +++ b/src/src/com/tns/Module.java @@ -249,18 +249,25 @@ static String bootstrapApp() // 2. Check for index.js // 3. Check for bootstrap.js - File bootstrapFile = resolvePathHelper("./", ""); - if (!bootstrapFile.exists()) - { - bootstrapFile = resolvePathHelper("./bootstrap", ""); + String notFoundMessage = "Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists. \\n If using typescript make sure your entry point file is transpiled to javascript."; + + // resolvePathHelper() never returns a non-existing file. Instead it throws an exception. + File bootstrapFile; + try { + bootstrapFile = resolvePathHelper("./", ""); + } catch (NativeScriptException ex) { + throw new NativeScriptException(notFoundMessage, ex); } - if (!bootstrapFile.exists()) - { - throw new NativeScriptException("Application entry point file not found. Please specify either package.json with main field, index.js or bootstrap.js!"); + if(bootstrapFile == null) { + try { + bootstrapFile = resolvePathHelper("./bootstrap", ""); + return bootstrapFile.getAbsolutePath(); + } catch (NativeScriptException ex) { + throw new NativeScriptException(notFoundMessage, ex); + } } - String modulePath = bootstrapFile.getAbsolutePath(); - return modulePath; + return bootstrapFile.getAbsolutePath(); } } From ecd7399907bac4ec77778f335ceacdb30aac4d16 Mon Sep 17 00:00:00 2001 From: Viktor Skarlatov Date: Mon, 6 Jun 2016 11:07:35 +0300 Subject: [PATCH 2/2] Removed some whitespace from an error message. --- src/src/com/tns/Module.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src/com/tns/Module.java b/src/src/com/tns/Module.java index 36d70c5b5..46c91d1f9 100644 --- a/src/src/com/tns/Module.java +++ b/src/src/com/tns/Module.java @@ -249,7 +249,7 @@ static String bootstrapApp() // 2. Check for index.js // 3. Check for bootstrap.js - String notFoundMessage = "Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists. \\n If using typescript make sure your entry point file is transpiled to javascript."; + String notFoundMessage = "Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\\nIf using typescript make sure your entry point file is transpiled to javascript."; // resolvePathHelper() never returns a non-existing file. Instead it throws an exception. File bootstrapFile;