Try ... catch statement
Posted: Thu Jun 11, 2009 2:34 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hello,
I have a problem with "try ... catch" statement in Javascript. I' m not sure if I have an error inside a code or I don't understand this statement well. Do you have any idea where is the mistake?
I' ve used framework mootools-1.2.1-core-jm.js.
Thanks for ANY suggestion.
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hello,
I have a problem with "try ... catch" statement in Javascript. I' m not sure if I have an error inside a code or I don't understand this statement well. Do you have any idea where is the mistake?
I' ve used framework mootools-1.2.1-core-jm.js.
Code: Select all
var Player = new Class(
{
initialize: function(dSpot,dDuration){
/**
* @var string DEFAULT_SPOT Defaultni spot
*/
DEFAULT_SPOT = "default.html";
/**
* @var int DEFAULT_DURATION Defaultni nastaveni casu;
*/
DEFAULT_DURATION = 1;
/**
* @var int DEFAULT_PRELOAD
*/
DEFAULT_PRELOAD = 1;
this.preload = DEFAULT_PRELOAD;
this.aSpot = null; //aktualni spot
this.nSpot = null; //nasledujici spot
if(!dSpot)
currentSpot = DEFAULT_SPOT;
else
currentSpot = dSpot;
if(!dDuration)
duration = DEFAULT_DURATION;
else
duration = dDuration;
this.nSpot = this.initSpot(currentSpot,duration);
this.show();
},
/**
* Nacte zadany spot;
*/
initSpot: function(spot,duration){
try {
r = new Request.HTML({
url: spot,
onSuccess: function(tree, elements, html){
alert('Success');
throw "Error";
},
onFailure: function(xhr){
alert('Failure');
}
});
r.send();
}catch(e){
alert(e);
}
//alert(PlayerException.PLAYER_REQUEST_ERROR);
},
show: function(){
},
buildSpot: function(){
alert('dsad');
}
}
);
var PlayerException = new Class(
{
initialize: function(result,content){
this.result = result;
this.content = content;
}
}
);
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: