9dc24f7d2e65235c20c42ac9c776c14201b6484f
[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 == """{"message":"ErrorMessage","cause":null,"error":"ErrorName"}"""
20 class NeoError
21 super Error
22 super Jsonable
23 serialize
24
25 # The name of the error.
26 #
27 # Used to programmatically distinguish this kind of error from others.
28 var name: String is serialize_as "error"
29
30 redef fun to_s do return "[{name}] {super}"
31 end