From 78a832b7f90c73e40fed86a67e26a6baa5489ec6 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 12 Jul 2006 23:56:00 +0000 Subject: [PATCH] Added a convenience method to get the message of a Throwable, or the class name if the message is null. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1875 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/StringUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/java/com/samskivert/util/StringUtil.java b/src/java/com/samskivert/util/StringUtil.java index ecc2c167..13089dcf 100644 --- a/src/java/com/samskivert/util/StringUtil.java +++ b/src/java/com/samskivert/util/StringUtil.java @@ -276,6 +276,19 @@ public class StringUtil return _ffmt.format(value); } + /** + * Get the message in the specified throwable, or the short class + * name if there is no message. + */ + public static String getMessage (Throwable t) + { + String msg = t.getMessage(); + if (msg == null) { + msg = shortClassName(t); + } + return msg; + } + /** * Converts the supplied object to a string. Normally this is * accomplished via the object's built in toString()