1
0
Fork 0

added some error codes

This commit is contained in:
a-brandt 2012-04-25 16:50:58 +02:00
parent 1d6fa6196c
commit d7e245f363
6 changed files with 42 additions and 11 deletions

View File

@ -167,6 +167,8 @@ ERROR_GRAPH_INVALID_GRAPH,1901,"invalid graph","Will be raised when an invalid n
ERROR_GRAPH_COULD_NOT_CREATE_GRAPH,1902,"could not create graph","Will be raised when an invalid name, vertices or edges is passed to the server"
ERROR_GRAPH_INVALID_VERTEX,1903,"invalid vertex","Will be raised when an invalid vertex id is passed to the server"
ERROR_GRAPH_COULD_NOT_CREATE_VERTEX,1904,"could not create vertex","Will be raised when the vertex could not be created"
ERROR_GRAPH_INVALID_EDGE,1905,"invalid edge","Will be raised when an invalid edge id is passed to the server"
ERROR_GRAPH_COULD_NOT_CREATE_EDGE,1906,"could not create edge","Will be raised when the edge could not be created"
################################################################################
## Simple Client

View File

@ -113,6 +113,8 @@ void TRI_InitialiseErrorMessages (void) {
REG_ERROR(ERROR_GRAPH_COULD_NOT_CREATE_GRAPH, "could not create graph");
REG_ERROR(ERROR_GRAPH_INVALID_VERTEX, "invalid vertex");
REG_ERROR(ERROR_GRAPH_COULD_NOT_CREATE_VERTEX, "could not create vertex");
REG_ERROR(ERROR_GRAPH_INVALID_EDGE, "invalid edge");
REG_ERROR(ERROR_GRAPH_COULD_NOT_CREATE_EDGE, "could not create edge");
REG_ERROR(SIMPLE_CLIENT_UNKNOWN_ERROR, "unknown client error");
REG_ERROR(SIMPLE_CLIENT_COULD_NOT_CONNECT, "could not connect to server");
REG_ERROR(SIMPLE_CLIENT_COULD_NOT_WRITE, "could not write to server");

View File

@ -245,6 +245,10 @@ extern "C" {
/// Will be raised when an invalid vertex id is passed to the server
/// - 1904: @CODE{could not create vertex}
/// Will be raised when the vertex could not be created
/// - 1905: @CODE{invalid edge}
/// Will be raised when an invalid edge id is passed to the server
/// - 1906: @CODE{could not create edge}
/// Will be raised when the edge could not be created
/// - 2000: @CODE{unknown client error}
/// This error should not happen.
/// - 2001: @CODE{could not connect to server}
@ -1325,6 +1329,26 @@ void TRI_InitialiseErrorMessages (void);
#define TRI_ERROR_GRAPH_COULD_NOT_CREATE_VERTEX (1904)
////////////////////////////////////////////////////////////////////////////////
/// @brief 1905: ERROR_GRAPH_INVALID_EDGE
///
/// invalid edge
///
/// Will be raised when an invalid edge id is passed to the server
////////////////////////////////////////////////////////////////////////////////
#define TRI_ERROR_GRAPH_INVALID_EDGE (1905)
////////////////////////////////////////////////////////////////////////////////
/// @brief 1906: ERROR_GRAPH_COULD_NOT_CREATE_EDGE
///
/// could not create edge
///
/// Will be raised when the edge could not be created
////////////////////////////////////////////////////////////////////////////////
#define TRI_ERROR_GRAPH_COULD_NOT_CREATE_EDGE (1906)
////////////////////////////////////////////////////////////////////////////////
/// @brief 2000: SIMPLE_CLIENT_UNKNOWN_ERROR
///

View File

@ -435,7 +435,7 @@ function postEdge(req, res) {
var json = JSON.parse(req.requestBody);
if (!json || !(json instanceof Object)) {
actions.resultBad(req, res, actions.ERROR_GRAPH_COULD_NOT_CREATE_VERTEX, "missing request body");
actions.resultBad(req, res, actions.ERROR_GRAPH_COULD_NOT_CREATE_EDGE, "missing request body");
return;
}
@ -453,7 +453,7 @@ function postEdge(req, res) {
actions.resultOk(req, res, actions.HTTP_OK, { "edge" : e._properties } );
}
catch (err) {
actions.resultBad(req, res, actions.ERROR_GRAPH_COULD_NOT_CREATE_VERTEX, err);
actions.resultBad(req, res, actions.ERROR_GRAPH_COULD_NOT_CREATE_EDGE, err);
}
}
@ -466,7 +466,7 @@ function postEdge(req, res) {
function getEdge(req, res) {
if (req.suffix.length < 1) {
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_VERTEX, "edge not found");
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_EDGE, "edge not found");
return;
}
@ -482,18 +482,17 @@ function getEdge(req, res) {
if (req.suffix.length > 1) {
id += "/" + req.suffix[1];
}
var e = new graph.Edge(g, id);
if (e == undefined || e._properties == undefined) {
throw "no edge found for: " + id + " " + e;
throw "no edge found for: " + id;
}
actions.resultOk(req, res, actions.HTTP_OK, { "edge" : e._properties} );
}
catch (err) {
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_VERTEX, err);
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_EDGE, err);
}
}
@ -506,7 +505,7 @@ function getEdge(req, res) {
function deleteEdge(req, res) {
if (req.suffix.length < 1) {
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_VERTEX, "edge not found");
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_EDGE, "edge not found");
return;
}
@ -523,10 +522,10 @@ function deleteEdge(req, res) {
id += "/" + req.suffix[1];
}
var e = g.getVertex(id);
var e = new graph.Edge(g, id);
if (e == undefined || e._properties == undefined) {
throw "no edge found";
throw "no edge found for: " + id;
}
g.removeEdge(e);
@ -534,7 +533,7 @@ function deleteEdge(req, res) {
actions.resultOk(req, res, actions.HTTP_OK, { "deleted" : true} );
}
catch (err) {
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_VERTEX, err);
actions.resultBad(req, res, actions.ERROR_GRAPH_INVALID_EDGE, err);
}
}

View File

@ -107,6 +107,8 @@ ModuleCache["/internal"].exports.errors = {
"ERROR_GRAPH_COULD_NOT_CREATE_GRAPH" : { "code" : 1902, "message" : "could not create graph" },
"ERROR_GRAPH_INVALID_VERTEX" : { "code" : 1903, "message" : "invalid vertex" },
"ERROR_GRAPH_COULD_NOT_CREATE_VERTEX" : { "code" : 1904, "message" : "could not create vertex" },
"ERROR_GRAPH_INVALID_EDGE" : { "code" : 1905, "message" : "invalid edge" },
"ERROR_GRAPH_COULD_NOT_CREATE_EDGE" : { "code" : 1906, "message" : "could not create edge" },
"SIMPLE_CLIENT_UNKNOWN_ERROR" : { "code" : 2000, "message" : "unknown client error" },
"SIMPLE_CLIENT_COULD_NOT_CONNECT" : { "code" : 2001, "message" : "could not connect to server" },
"SIMPLE_CLIENT_COULD_NOT_WRITE" : { "code" : 2002, "message" : "could not write to server" },

View File

@ -108,6 +108,8 @@ static string JS_common_bootstrap_errors =
" \"ERROR_GRAPH_COULD_NOT_CREATE_GRAPH\" : { \"code\" : 1902, \"message\" : \"could not create graph\" }, \n"
" \"ERROR_GRAPH_INVALID_VERTEX\" : { \"code\" : 1903, \"message\" : \"invalid vertex\" }, \n"
" \"ERROR_GRAPH_COULD_NOT_CREATE_VERTEX\" : { \"code\" : 1904, \"message\" : \"could not create vertex\" }, \n"
" \"ERROR_GRAPH_INVALID_EDGE\" : { \"code\" : 1905, \"message\" : \"invalid edge\" }, \n"
" \"ERROR_GRAPH_COULD_NOT_CREATE_EDGE\" : { \"code\" : 1906, \"message\" : \"could not create edge\" }, \n"
" \"SIMPLE_CLIENT_UNKNOWN_ERROR\" : { \"code\" : 2000, \"message\" : \"unknown client error\" }, \n"
" \"SIMPLE_CLIENT_COULD_NOT_CONNECT\" : { \"code\" : 2001, \"message\" : \"could not connect to server\" }, \n"
" \"SIMPLE_CLIENT_COULD_NOT_WRITE\" : { \"code\" : 2002, \"message\" : \"could not write to server\" }, \n"