[AC-3053] "Ti.include" throws uncatchable exception when file don't exist
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2011-07-09T04:55:17.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Ivan Skugor |
Assignee | Tony Guntharp |
Created | 2011-07-08T01:27:53.000+0000 |
Updated | 2016-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
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
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
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.