mengdiwang / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Exception from HostSpecific.from(String) leaves out useful information #507

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When throwing an exception in a catch block please always set the initCause() 
to the original exception.

For example, in HostSpecifier, notice how the comment in the catch block notes 
that "the IAE can originate at several different points inside fromValid()" and 
this code makes damn certain that the exact location will continue to be 
mysterious! Why the secrecy? Debugging production server exceptions are hard 
enough, please show *all* available information! There is no reason why the new 
ParseException can not have its initCause set to the IAE!

line 122 (r07):
  public static HostSpecifier from(String specifier)
      throws ParseException {
    try {
      return fromValid(specifier);
    } catch (IllegalArgumentException e) {
      // Since the IAE can originate at several different points inside
      // fromValid(), we implement this method in terms of that one rather
      // than the reverse.

      throw new ParseException("Invalid host specifier: " + specifier, 0);
    }
  }

Original issue reported on code.google.com by transpar...@gmail.com on 28 Dec 2010 at 2:16

GoogleCodeExporter commented 9 years ago
Probably an oversight.  We'll look into it.  As much as possible, the chain of 
exception messages plus the text of the API documentation should together be 
sufficient to pinpoint any problem.

If there are other such problems found, please report them.

Original comment by kevinb@google.com on 12 Jan 2011 at 9:34

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 20 Jan 2011 at 6:56

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 24 Jan 2011 at 9:51

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09