classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: improve error handling in String


From: Anthony Green
Subject: Re: [cp-patches] Patch: improve error handling in String
Date: Thu, 15 Sep 2005 17:57:24 -0700

On Thu, 2005-09-15 at 09:24 -0700, David Daney wrote:
> Too bad if the type that should be thrown does not have a constructor 
> that takes a chained Throwable as its cause.  If this is the case use 
> Throwable.initCause().  There is a reason that this method exists:  It 
> is so that we can use it to report the best information available about 
> what went wrong.

Ok, how about this then....

AG


Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.70
diff -u -r1.70 String.java
--- java/lang/String.java       13 Sep 2005 22:19:15 -0000      1.70
+++ java/lang/String.java       16 Sep 2005 00:55:59 -0000
@@ -641,8 +641,10 @@
          throw new UnsupportedEncodingException("Encoding: "+enc+
                                                 " not found.");
       } catch(CharacterCodingException e){
-         // XXX - Ignore coding exceptions? They shouldn't really happen.
-         return null;
+       // This shouldn't really happen.
+        InternalError ie = new InternalError();
+       ie.initCause(e);
+       throw ie;
       }          
   }
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]