I have array of names
var names = ['X', 'Y']
For each name i want to create class instance but only if proper js file exists otherwise function should return null
getTool:function(name) {
var t = Ext.create('VC.tools.' + name + 'Tool',{
map:this.map
});
return t.getEntryPoint();
}
Or maybe is there a way of implementing some kind of try catch? I just dont want any errors like file could not be loaded etc.
EDIT:
If i add try catch i can avoid is not a constructor error. But still got file not exists error. Is there a way of handling this?
try {
var t = Ext.create('VC.tools.' + name + 'Tool',{
map:this.map
});
return t.getEntryPoint();
}catch(err){
return null;
}