update NOTICE
[nit.git] / lib / neo4j / 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 thrown by the `neo4j` library.
12 module neo4j::error
13
14 import json::static
15
16 # An error thrown by the `neo4j` API.
17 #
18 # var error = new NeoError("ErrorMessage", "ErrorName")
19 # assert error.to_json == "\{\"error\":\"ErrorName\",\"message\":\"ErrorMessage\"\}"
20 class NeoError
21 super Error
22 super Jsonable
23
24 # The name of the error.
25 #
26 # Used to programmatically distinguish this kind of error from others.
27 var name: String
28
29 redef fun to_json do
30 return "\{\"error\":{name.to_json},\"message\":{message.to_json}\}"
31 end
32
33 redef fun to_s do return "[{name}] {super}"
34 end