Fix issue #203 - errors in Util.exception when no trace present.

This commit is contained in:
md_5 2013-03-15 20:38:40 +11:00
parent bd479ba083
commit d6e29b3f29

View File

@ -68,6 +68,9 @@ public class Util
*/
public static String exception(Throwable t)
{
return t.getClass().getSimpleName() + " : " + t.getMessage() + " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber();
// TODO: We should use clear manually written exceptions
StackTraceElement[] trace = t.getStackTrace();
return t.getClass().getSimpleName() + " : " + t.getMessage()
+ ( ( trace.length > 0 ) ? " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber() : "" );
}
}