maskedMan
05-22-2008, 01:21 AM
Hello there,
I'm running into a problem where I'm trying to silence a runtime error. Here's the bare bones of it:
class HasDictionary{
//only has this variable...
public var $list:Dictionary = new Dictionary();
//various functions...
}
import hasDictionary;
class anotherClass{
private var $myList:hasDictionary = new HasDictionary();
public function insertAfterID(index:*, item:*):Boolean{
try{
//error happens here when $myList.$list doesn't have a property === index;
var n:Object = $myList.$list[index];
}catch(e:Error){
trace("I don't care, just keep going");
return false;
}finally{
//do stuff with n
return true;
}
}
}
Thing is, I don't care if $myList.$list[index] exists or not. If it doesn't I just want the function to return false, but it isn't doing that. It's throwing an error and crashing the program. I just want the error to be silenced and for the program to continue on its merry way. try...catch...finally seems not to actually work for some reason, as it isn't catching the error. What am I doing wrong here?
I'm running into a problem where I'm trying to silence a runtime error. Here's the bare bones of it:
class HasDictionary{
//only has this variable...
public var $list:Dictionary = new Dictionary();
//various functions...
}
import hasDictionary;
class anotherClass{
private var $myList:hasDictionary = new HasDictionary();
public function insertAfterID(index:*, item:*):Boolean{
try{
//error happens here when $myList.$list doesn't have a property === index;
var n:Object = $myList.$list[index];
}catch(e:Error){
trace("I don't care, just keep going");
return false;
}finally{
//do stuff with n
return true;
}
}
}
Thing is, I don't care if $myList.$list[index] exists or not. If it doesn't I just want the function to return false, but it isn't doing that. It's throwing an error and crashing the program. I just want the error to be silenced and for the program to continue on its merry way. try...catch...finally seems not to actually work for some reason, as it isn't catching the error. What am I doing wrong here?