/    Sign up×
Community /Pin to ProfileBookmark

printing exception message

can anyone please tell me how to print exception message?

try{
.
.
.
catch(e)
{
e.getMessage();
}

the above code i tried produced script error itself. i am a bit confused about how i can get the exception message.
can anyone please help me?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mrhooMay 19.2006 — catch(er){ alerts(er.message);}

or something like:

catch(er){

errorLog.push(er.message);

}

or:

catch(er) {

Yikes(er,false);

}

[CODE]function Yikes(er,boo){
var temp,tem,str='';
if(er && er.message){
var fun= arguments.callee.caller;
var eor= ['fileName','lineNumber','message','name','number'];
YikesLoop:
for(var i= 0; i< 5; i++){
tem= eor[i];
temp= er[tem];
if(temp){
if(tem== 'fileName' ) tem=' file';
else if(tem=='lineNumber') tem= 'line';
str+= 'n'+ tem+ '='+ temp;
}
}
if(fun && fun.named) str+= 'nError thrown from:'+ fun.named();
}
else str= er;

if(!str)str= 'Yikes!';
if(typeof(errorLog)=='object' && errorLog.push) errorLog.push(str);
if(typeof(yw_alert)=='function' && boo===true) yw_alert('Yikes!',str);
else if(boo) alert(str);
return true;
}
[/CODE]


[CODE] Function.prototype.named= function(){
var tem= this.toString().match(/functions+(w+)(/);
return (tem)? tem[1]: 'anonymous';
};[/CODE]
×

Success!

Help @joydeep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...