wangyao5 / json-smart

Automatically exported from code.google.com/p/json-smart
0 stars 0 forks source link

net.minidev.json.parser.ParseException should NOToverride toString() but getMessage() #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Right now the ParseException's 'toString' method is overridden. Which
leaves the get[Localized]Message methods returning NULL. 

This bug is very annoying because it breaks standard error-handling code,
due to:

1. It breaks the typical exception.toString() implementation not to report its 
name first
(this is the most disturbing).

2. The exception does not have an exception-message at all.

Obviously the bug was copied from json-simple, see respective issue-5 there.

What steps will reproduce the problem?
1. Capture any net.minidev.json.parser.ParseException.
2. The 'getMessage' or 'getLocalizedMessage' return NULL (although there is a 
message returned by toString)
4. The toString() does not report exception-name.

VERSION: 1.1.1, module: v1 (have not checked v2)

FIX

---
Please, 
a) move the code from ParseException.toString() to ParseException.getMessage(),
and 
b) stop overridding toString() method.

Original issue reported on code.google.com by ankos...@gmail.com on 11 Apr 2013 at 6:29

GoogleCodeExporter commented 9 years ago
Sorry, to FIX it just (b) is enough,
that is, 
  stop overriding toString() method".

Original comment by ankos...@gmail.com on 14 Apr 2013 at 10:53

GoogleCodeExporter commented 9 years ago
I want to keep overloading toString() in JSONArray and JSONObject.

Apart from these two classes, I will restore the toString() in my other classes.

Original comment by uriel.chemouni on 30 Jul 2013 at 7:04

GoogleCodeExporter commented 9 years ago
the toString() overload is now removed from ParseException.java

Original comment by uriel.chemouni on 30 Jul 2013 at 7:09

GoogleCodeExporter commented 9 years ago

Original comment by uriel.chemouni on 14 Aug 2013 at 1:10