[Actionframework-users] Exceptions: Stack Trace (to Sagar Saladi)
Status: Inactive
Brought to you by:
ptoman
From: <ser...@is...> - 2004-05-13 15:18:19
|
Hi there! I'm not a member of the list, soi cant post this answer in the forum.=20 Anyway, i would like to help with my answer, that answers a post from=20 Sagar Saladi about retrievin the Stack Trace of an error. I have a bit of code that can help you. Just declare the exception in=20 the xml file like this: <on-exception class=3D"java/lang/NullPointerException" assign-to=3D"npe"=20 show-template=3D"error.vm"> <output-variable name=3D"obj" value=3D"$npe"/> </on-exception> And the, in the "error.vm" code, add this: <form name=3D"frmStack"> <div id=3D"show"> <input type=3D"button" value=3D"Show stack trace" id=3D"btnShowSt= ack"=20 onclick=3D"showStack()"> </div> =20 <div id=3D"hide" style=3D"display:none"> <input type=3D"button" value=3D"Hide stack trace" id=3D"btnHideSt= ack"=20 onclick=3D"hideStack()"> </div> </form> <div id=3D"stack" style=3D"display:none"> <strong><font color=3D"blue">Stack trace:</font></strong> <br> <p><TT> <hr> #foreach($call in $obj.getStackTrace()) $velocityCount - $call.getFileName() (line $call.getLineNumber()):=20 $call.getClassName() -> $call.getMethodName() <br> #end <hr> </TT></p> </div> And, last but not least, add a jscript file to the error.vm with the=20 following code: function showStack() { document.getElementById('show').style.display=3D'none'; =20 document.getElementById('hide').style.display=3D'block'; document.getElementById('stack').style.display=3D'block'; } function hideStack() { document.getElementById('hide').style.display=3D'none'; =20 document.getElementById('show').style.display=3D'block'; =20 document.getElementById('stack').style.display=3D'none'; } That's all. I hope it helps you, Regards --=20 Seraf=EDn Orill=E1n Chaparro Isotrol S.A. Avda. de la Innovaci=F3n s/n +34 955 036 800 e-mail: ser...@is... |