getStackTrace()
Last updated July 01, 2011
Version: 2 | Requires: CF9 | Library: UtilityLib
Description:
Gets the current stack trace, even if no error was thrown, and returns it in a query.
Return Values:
Returns a query.
Example:
<cfdump label="StackTrace" var="#getStacktrace()#">
Parameters:
No arguments.
Full UDF Source:
/**
* Gets the current stack trace, even if no error was thrown, and returns it in a query.
* Removed var e as it breaks in CF9
*
* @return Returns a query.
* @author Ivo D. SIlva (aphex@netvisao.pt)
* @version 2, July 1, 2011
*/
function getStackTrace() {
var j = "";
var i = "";
var StackTrace = "";
try
{
j = CreateObject("java","java.lang.Throwable");
j = j.getStackTrace();
StackTrace = QueryNew("ClassName,MethodName,NativeMethod,LineNumber,hashCode");
QueryAddRow(StackTrace,ArrayLen(j));
for (i=1; i le ArrayLen(j); i = i+1)
{
QuerySetCell(StackTrace,'ClassName',j[i].getClassName(),i);
QuerySetCell(StackTrace,'MethodName',j[i].getMethodName(),i);
QuerySetCell(StackTrace,'NativeMethod',j[i].isNativeMethod(),i);
QuerySetCell(StackTrace,'LineNumber',j[i].getLineNumber(),i);
QuerySetCell(StackTrace,'hashCode',j[i].hashCode(),i);
}
}
catch ( any e )
{
return e;
}
return StackTrace;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016