javacommons/utils/javasrc/com/nokia/mj/impl/utils/DebugUtils.java
changeset 79 2f468c1958d0
parent 76 4ad59aaee882
child 80 d6dafc5d983f
--- a/javacommons/utils/javasrc/com/nokia/mj/impl/utils/DebugUtils.java	Fri Sep 17 08:28:21 2010 +0300
+++ b/javacommons/utils/javasrc/com/nokia/mj/impl/utils/DebugUtils.java	Mon Oct 04 00:10:53 2010 +0300
@@ -59,13 +59,22 @@
 
     public static String getStackTrace(Throwable t)
     {
-        if (t == null)
+        String res = null;
+        if (t != null)
         {
-            throw new NullPointerException("Null when getting stack trace");
+            try 
+            {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                _getStackTrace(t, new PrintStream(baos));
+                res = baos.toString();
+            }
+            catch (Throwable t2)
+            {
+                System.err.println("Failure in getting stack trace.");
+                t2.printStackTrace();
+            }
         }
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        _getStackTrace(t, new PrintStream(baos));
-        return baos.toString();
+        return res;
     }
 
     private static native void _getStackTrace(Throwable t, PrintStream printStream);