Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3053] "Ti.include" throws uncatchable exception when file don't exist

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2011-07-09T04:55:17.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvan Skugor
AssigneeTony Guntharp
Created2011-07-08T01:27:53.000+0000
Updated2016-03-08T07:48:05.000+0000

Description

Hi. "Ti.include" throws uncatchable exception when trying to include file that don't exists. Following code demonstrates the issue:
try {
    Ti.include('/file/that/dont/exist.js');
}
catch(e) {
    Ti.API.error(e.message);
}
This code throws "java.io.FileNotFoundException" that can't be caught. Q/A: http://developer.appcelerator.com/question/121769/catch-tiinclude-file-not-found-exception

Comments

  1. Paul Dowsett 2011-07-09

    Ivan, what you are asking does not make sense at all. You should not ship an app that has missing files. Hence, an exception is the best way of preventing this. Please let me know if I have overlooked a reasonable situation where it should indeed be done. Thanks
  2. Paul Dowsett 2011-07-09

    btw, including the SDK build date and hash is required when submitting tickets. Please refer to [Jira Ticket Checklist](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist). Thanks
  3. Ivan Skugor 2011-07-11

    Hi Paul. I've updated ticket with SDK build date and hash. As for your comment, I agree with you. But, in dynamic scenarios (and with respect on variety of mobile and tablet application purposes and implementations) you can't predict and test any possible situation and exceptions are possible (including exceptions generated by "Ti.include"). What I would like to have is ability to control situations when exception is thrown (log errors for example, recover from exception, etc.). This particular exception can be avoided using "file.exists()", but IMHO, using try-catch block is semantically correct approach. You can leave this as it is now, but then at least update documentation with explanation that "Ti.include" throws uncatchable exception if file is not found. Thanks.

JSON Source