a_star: don't crash on deserialization errors and limit static types
[nit.git] / lib / json / error.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
9 # another product.
10
11 # Errors related to JSON parsing.
12 module json::error
13
14 import nitcc_runtime
15
16 # Ill-formed JSON.
17 class JsonParseError
18 super Error
19 serialize
20
21 # The location of the error in the original text.
22 var position: nullable Position
23
24 redef fun to_s do
25 var p = position
26 if p isa Position then
27 return "Error Parsing JSON: [{p}] {super}"
28 else
29 return super
30 end
31 end
32 end