Skip to content

Commit 92ccaf8

Browse files
committed
Added a more descriptive error message in the app boostrap.
1 parent 0050c77 commit 92ccaf8

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/src/com/tns/Module.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,25 @@ static String bootstrapApp()
249249
// 2. Check for index.js
250250
// 3. Check for bootstrap.js
251251

252-
File bootstrapFile = resolvePathHelper("./", "");
253-
if (!bootstrapFile.exists())
254-
{
255-
bootstrapFile = resolvePathHelper("./bootstrap", "");
252+
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.";
253+
254+
// resolvePathHelper() never returns a non-existing file. Instead it throws an exception.
255+
File bootstrapFile;
256+
try {
257+
bootstrapFile = resolvePathHelper("./", "");
258+
} catch (NativeScriptException ex) {
259+
throw new NativeScriptException(notFoundMessage, ex);
256260
}
257261

258-
if (!bootstrapFile.exists())
259-
{
260-
throw new NativeScriptException("Application entry point file not found. Please specify either package.json with main field, index.js or bootstrap.js!");
262+
if(bootstrapFile == null) {
263+
try {
264+
bootstrapFile = resolvePathHelper("./bootstrap", "");
265+
return bootstrapFile.getAbsolutePath();
266+
} catch (NativeScriptException ex) {
267+
throw new NativeScriptException(notFoundMessage, ex);
268+
}
261269
}
262270

263-
String modulePath = bootstrapFile.getAbsolutePath();
264-
return modulePath;
271+
return bootstrapFile.getAbsolutePath();
265272
}
266273
}

0 commit comments

Comments
 (0)