mirror of https://gitee.com/bigwinds/arangodb
fixed error messages and tests
This commit is contained in:
parent
3512fa6ff0
commit
42b92c794f
|
@ -453,7 +453,7 @@ int AttributeNamesFromArguments (v8::Arguments const& argv,
|
||||||
error = "invalid attribute name";
|
error = "invalid attribute name";
|
||||||
|
|
||||||
TRI_FreeContentVectorPointer(TRI_CORE_MEM_ZONE, result);
|
TRI_FreeContentVectorPointer(TRI_CORE_MEM_ZONE, result);
|
||||||
return TRI_set_errno(TRI_ERROR_ILLEGAL_OPTION);
|
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_Utf8ValueNFC argumentString(TRI_UNKNOWN_MEM_ZONE, argument);
|
TRI_Utf8ValueNFC argumentString(TRI_UNKNOWN_MEM_ZONE, argument);
|
||||||
|
@ -471,7 +471,7 @@ int AttributeNamesFromArguments (v8::Arguments const& argv,
|
||||||
error = "invalid attribute name";
|
error = "invalid attribute name";
|
||||||
|
|
||||||
TRI_FreeContentVectorPointer(TRI_CORE_MEM_ZONE, result);
|
TRI_FreeContentVectorPointer(TRI_CORE_MEM_ZONE, result);
|
||||||
return TRI_set_errno(TRI_ERROR_ILLEGAL_OPTION);
|
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_PushBackVectorPointer(result, cArgument);
|
TRI_PushBackVectorPointer(result, cArgument);
|
||||||
|
@ -491,7 +491,7 @@ int AttributeNamesFromArguments (v8::Arguments const& argv,
|
||||||
error = "duplicate attribute names";
|
error = "duplicate attribute names";
|
||||||
|
|
||||||
TRI_FreeContentVectorPointer(TRI_CORE_MEM_ZONE, result);
|
TRI_FreeContentVectorPointer(TRI_CORE_MEM_ZONE, result);
|
||||||
return TRI_set_errno(TRI_ERROR_ILLEGAL_OPTION);
|
return TRI_set_errno(TRI_ERROR_BAD_PARAMETER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3703,7 +3703,7 @@ static v8::Handle<v8::Value> EnsureBitarray (v8::Arguments const& argv, bool sup
|
||||||
|
|
||||||
if (! argument->IsString() ) {
|
if (! argument->IsString() ) {
|
||||||
errorString = "invalid parameter -- expected string parameter";
|
errorString = "invalid parameter -- expected string parameter";
|
||||||
errorCode = TRI_ERROR_ILLEGAL_OPTION;
|
errorCode = TRI_ERROR_BAD_PARAMETER;
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3722,12 +3722,11 @@ static v8::Handle<v8::Value> EnsureBitarray (v8::Arguments const& argv, bool sup
|
||||||
|
|
||||||
if (! argument->IsArray() ) {
|
if (! argument->IsArray() ) {
|
||||||
errorString = "invalid parameter -- expected an array (list)";
|
errorString = "invalid parameter -- expected an array (list)";
|
||||||
errorCode = TRI_ERROR_ILLEGAL_OPTION;
|
errorCode = TRI_ERROR_BAD_PARAMETER;
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// .........................................................................
|
// .........................................................................
|
||||||
// Attempt to convert the V8 javascript function argument into a TRI_json_t
|
// Attempt to convert the V8 javascript function argument into a TRI_json_t
|
||||||
// .........................................................................
|
// .........................................................................
|
||||||
|
@ -3741,7 +3740,7 @@ static v8::Handle<v8::Value> EnsureBitarray (v8::Arguments const& argv, bool sup
|
||||||
|
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
errorString = "invalid parameter -- expected an array (list)";
|
errorString = "invalid parameter -- expected an array (list)";
|
||||||
errorCode = TRI_ERROR_ILLEGAL_OPTION;
|
errorCode = TRI_ERROR_BAD_PARAMETER;
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3753,7 +3752,7 @@ static v8::Handle<v8::Value> EnsureBitarray (v8::Arguments const& argv, bool sup
|
||||||
|
|
||||||
if (value->_type != TRI_JSON_LIST) {
|
if (value->_type != TRI_JSON_LIST) {
|
||||||
errorString = "invalid parameter -- expected an array (list)";
|
errorString = "invalid parameter -- expected an array (list)";
|
||||||
errorCode = TRI_ERROR_ILLEGAL_OPTION;
|
errorCode = TRI_ERROR_BAD_PARAMETER;
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3772,13 +3771,11 @@ static v8::Handle<v8::Value> EnsureBitarray (v8::Arguments const& argv, bool sup
|
||||||
|
|
||||||
if (attributes._length != values._length) {
|
if (attributes._length != values._length) {
|
||||||
errorString = "invalid parameter -- expected an array (list)";
|
errorString = "invalid parameter -- expected an array (list)";
|
||||||
errorCode = TRI_ERROR_ILLEGAL_OPTION;
|
errorCode = TRI_ERROR_BAD_PARAMETER;
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// Actually create the index here
|
// Actually create the index here
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
@ -3786,6 +3783,7 @@ static v8::Handle<v8::Value> EnsureBitarray (v8::Arguments const& argv, bool sup
|
||||||
if (ok) {
|
if (ok) {
|
||||||
char* errorStr = 0;
|
char* errorStr = 0;
|
||||||
bitarrayIndex = TRI_EnsureBitarrayIndexDocumentCollection(document, &attributes, &values, supportUndef, &indexCreated, &errorCode, &errorStr);
|
bitarrayIndex = TRI_EnsureBitarrayIndexDocumentCollection(document, &attributes, &values, supportUndef, &indexCreated, &errorCode, &errorStr);
|
||||||
|
|
||||||
if (bitarrayIndex == 0) {
|
if (bitarrayIndex == 0) {
|
||||||
if (errorStr == 0) {
|
if (errorStr == 0) {
|
||||||
errorString = "index could not be created from Simple Collection";
|
errorString = "index could not be created from Simple Collection";
|
||||||
|
|
|
@ -2780,7 +2780,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (struct TRI_primary_collection_s* primary,
|
||||||
|
|
||||||
if (valueList == NULL || valueList->_type != TRI_JSON_LIST) {
|
if (valueList == NULL || valueList->_type != TRI_JSON_LIST) {
|
||||||
LOG_WARNING("bitarray index creation failed -- list of values for index undefined");
|
LOG_WARNING("bitarray index creation failed -- list of values for index undefined");
|
||||||
*errorNum = TRI_ERROR_ILLEGAL_OPTION;
|
*errorNum = TRI_ERROR_BAD_PARAMETER;
|
||||||
*errorStr = TRI_DuplicateString("bitarray index creation failed -- list of values for index undefined");
|
*errorStr = TRI_DuplicateString("bitarray index creation failed -- list of values for index undefined");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
"ERROR_FILE_NOT_FOUND" : { "code" : 14, "message" : "file not found" },
|
"ERROR_FILE_NOT_FOUND" : { "code" : 14, "message" : "file not found" },
|
||||||
"ERROR_CANNOT_WRITE_FILE" : { "code" : 15, "message" : "cannot write file" },
|
"ERROR_CANNOT_WRITE_FILE" : { "code" : 15, "message" : "cannot write file" },
|
||||||
"ERROR_CANNOT_OVERWRITE_FILE" : { "code" : 16, "message" : "cannot overwrite file" },
|
"ERROR_CANNOT_OVERWRITE_FILE" : { "code" : 16, "message" : "cannot overwrite file" },
|
||||||
|
"ERROR_TYPE_ERROR" : { "code" : 17, "message" : "type error" },
|
||||||
"ERROR_HTTP_BAD_PARAMETER" : { "code" : 400, "message" : "bad parameter" },
|
"ERROR_HTTP_BAD_PARAMETER" : { "code" : 400, "message" : "bad parameter" },
|
||||||
"ERROR_HTTP_FORBIDDEN" : { "code" : 403, "message" : "forbidden" },
|
"ERROR_HTTP_FORBIDDEN" : { "code" : 403, "message" : "forbidden" },
|
||||||
"ERROR_HTTP_NOT_FOUND" : { "code" : 404, "message" : "not found" },
|
"ERROR_HTTP_NOT_FOUND" : { "code" : 404, "message" : "not found" },
|
||||||
|
|
|
@ -287,7 +287,13 @@ exports.printTable = function (list, columns, framed) {
|
||||||
fixedLength = columns[col] >= pad.length ? columns[col] : pad.length;
|
fixedLength = columns[col] >= pad.length ? columns[col] : pad.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptions.push({ id: col, name: col, fixedLength: fixedLength, length: fixedLength || col.length });
|
descriptions.push({
|
||||||
|
id: col,
|
||||||
|
name: col,
|
||||||
|
fixedLength: fixedLength,
|
||||||
|
length: fixedLength || col.length
|
||||||
|
});
|
||||||
|
|
||||||
matrix[0][j++] = col;
|
matrix[0][j++] = col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,18 +90,23 @@ exports.createHelpHeadline = function (text) {
|
||||||
|
|
||||||
// must came after the export of createHelpHeadline
|
// must came after the export of createHelpHeadline
|
||||||
var ArangoError = require("org/arangodb/arango-error").ArangoError;
|
var ArangoError = require("org/arangodb/arango-error").ArangoError;
|
||||||
|
var arangodb = require("org/arangodb");
|
||||||
|
|
||||||
exports.checkRequestResult = function (requestResult) {
|
exports.checkRequestResult = function (requestResult) {
|
||||||
if (requestResult === undefined) {
|
if (requestResult === undefined) {
|
||||||
requestResult = {
|
requestResult = {
|
||||||
"error" : true,
|
"error" : true,
|
||||||
"code" : 0,
|
"code" : 500,
|
||||||
"errorNum" : 0,
|
"errorNum" : arangodb.ERROR_INTERNAL,
|
||||||
"errorMessage" : "Unknown error. Request result is empty"
|
"errorMessage" : "Unknown error. Request result is empty"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestResult.error !== undefined && requestResult.error) {
|
if (requestResult.error !== undefined && requestResult.error) {
|
||||||
|
if (requestResult.errorNum === arangodb.ERROR_TYPE_ERROR) {
|
||||||
|
throw new TypeError(requestResult.errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
throw new ArangoError(requestResult);
|
throw new ArangoError(requestResult);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,18 +89,23 @@ exports.createHelpHeadline = function (text) {
|
||||||
|
|
||||||
// must came after the export of createHelpHeadline
|
// must came after the export of createHelpHeadline
|
||||||
var ArangoError = require("org/arangodb/arango-error").ArangoError;
|
var ArangoError = require("org/arangodb/arango-error").ArangoError;
|
||||||
|
var arangodb = require("org/arangodb");
|
||||||
|
|
||||||
exports.checkRequestResult = function (requestResult) {
|
exports.checkRequestResult = function (requestResult) {
|
||||||
if (requestResult === undefined) {
|
if (requestResult === undefined) {
|
||||||
requestResult = {
|
requestResult = {
|
||||||
"error" : true,
|
"error" : true,
|
||||||
"code" : 0,
|
"code" : 500,
|
||||||
"errorNum" : 0,
|
"errorNum" : arangodb.ERROR_INTERNAL,
|
||||||
"errorMessage" : "Unknown error. Request result is empty"
|
"errorMessage" : "Unknown error. Request result is empty"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestResult.error !== undefined && requestResult.error) {
|
if (requestResult.error !== undefined && requestResult.error) {
|
||||||
|
if (requestResult.errorNum === arangodb.ERROR_TYPE_ERROR) {
|
||||||
|
throw new TypeError(requestResult.errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
throw new ArangoError(requestResult);
|
throw new ArangoError(requestResult);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
"ERROR_FILE_NOT_FOUND" : { "code" : 14, "message" : "file not found" },
|
"ERROR_FILE_NOT_FOUND" : { "code" : 14, "message" : "file not found" },
|
||||||
"ERROR_CANNOT_WRITE_FILE" : { "code" : 15, "message" : "cannot write file" },
|
"ERROR_CANNOT_WRITE_FILE" : { "code" : 15, "message" : "cannot write file" },
|
||||||
"ERROR_CANNOT_OVERWRITE_FILE" : { "code" : 16, "message" : "cannot overwrite file" },
|
"ERROR_CANNOT_OVERWRITE_FILE" : { "code" : 16, "message" : "cannot overwrite file" },
|
||||||
|
"ERROR_TYPE_ERROR" : { "code" : 17, "message" : "type error" },
|
||||||
"ERROR_HTTP_BAD_PARAMETER" : { "code" : 400, "message" : "bad parameter" },
|
"ERROR_HTTP_BAD_PARAMETER" : { "code" : 400, "message" : "bad parameter" },
|
||||||
"ERROR_HTTP_FORBIDDEN" : { "code" : 403, "message" : "forbidden" },
|
"ERROR_HTTP_FORBIDDEN" : { "code" : 403, "message" : "forbidden" },
|
||||||
"ERROR_HTTP_NOT_FOUND" : { "code" : 404, "message" : "not found" },
|
"ERROR_HTTP_NOT_FOUND" : { "code" : 404, "message" : "not found" },
|
||||||
|
|
|
@ -1639,10 +1639,10 @@ function resultException (req, res, err, headers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg === "") {
|
if (msg === "") {
|
||||||
msg = String(err) + " " + String(err.stack);
|
msg = String(err) + ": " + String(err.stack);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg += " " + String(err.stack);
|
msg += ": " + String(err.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (num) {
|
switch (num) {
|
||||||
|
@ -1659,9 +1659,9 @@ function resultException (req, res, err, headers) {
|
||||||
resultError(req, res, code, num, msg, headers);
|
resultError(req, res, code, num, msg, headers);
|
||||||
}
|
}
|
||||||
else if (err instanceof TypeError) {
|
else if (err instanceof TypeError) {
|
||||||
num = arangodb.ERROR_HTTP_BAD_PARAMETER;
|
num = arangodb.ERROR_TYPE_ERROR;
|
||||||
code = exports.HTTP_BAD;
|
code = exports.HTTP_BAD;
|
||||||
msg = String(err.message) + " " + String(err.stack);
|
msg = String(err.message) + ": " + String(err.stack);
|
||||||
|
|
||||||
resultError(req, res, code, num, msg, headers);
|
resultError(req, res, code, num, msg, headers);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ ERROR_CORRUPTED_CSV,13,"csv is corrupt","Will be raised when encountering a corr
|
||||||
ERROR_FILE_NOT_FOUND,14,"file not found","Will be raised when a file is not found."
|
ERROR_FILE_NOT_FOUND,14,"file not found","Will be raised when a file is not found."
|
||||||
ERROR_CANNOT_WRITE_FILE,15,"cannot write file","Will be raised when a file cannot be written."
|
ERROR_CANNOT_WRITE_FILE,15,"cannot write file","Will be raised when a file cannot be written."
|
||||||
ERROR_CANNOT_OVERWRITE_FILE,16,"cannot overwrite file","Will be raised when an attempt is made to overwrite an existing file."
|
ERROR_CANNOT_OVERWRITE_FILE,16,"cannot overwrite file","Will be raised when an attempt is made to overwrite an existing file."
|
||||||
|
ERROR_TYPE_ERROR,17,"type error","Will be raised when a type error is unencountered."
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## HTTP standard errors
|
## HTTP standard errors
|
||||||
|
|
|
@ -28,6 +28,7 @@ void TRI_InitialiseErrorMessages (void) {
|
||||||
REG_ERROR(ERROR_FILE_NOT_FOUND, "file not found");
|
REG_ERROR(ERROR_FILE_NOT_FOUND, "file not found");
|
||||||
REG_ERROR(ERROR_CANNOT_WRITE_FILE, "cannot write file");
|
REG_ERROR(ERROR_CANNOT_WRITE_FILE, "cannot write file");
|
||||||
REG_ERROR(ERROR_CANNOT_OVERWRITE_FILE, "cannot overwrite file");
|
REG_ERROR(ERROR_CANNOT_OVERWRITE_FILE, "cannot overwrite file");
|
||||||
|
REG_ERROR(ERROR_TYPE_ERROR, "type error");
|
||||||
REG_ERROR(ERROR_HTTP_BAD_PARAMETER, "bad parameter");
|
REG_ERROR(ERROR_HTTP_BAD_PARAMETER, "bad parameter");
|
||||||
REG_ERROR(ERROR_HTTP_FORBIDDEN, "forbidden");
|
REG_ERROR(ERROR_HTTP_FORBIDDEN, "forbidden");
|
||||||
REG_ERROR(ERROR_HTTP_NOT_FOUND, "not found");
|
REG_ERROR(ERROR_HTTP_NOT_FOUND, "not found");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#ifndef TRIAGENS_BASICS_C_ERRORS_H
|
#ifndef TRIAGENS_BASICS_C_VOC_ERRORS_H
|
||||||
#define TRIAGENS_BASICS_C_ERRORS_H 1
|
#define TRIAGENS_BASICS_C_VOC_ERRORS_H 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -45,6 +45,8 @@ extern "C" {
|
||||||
/// Will be raised when a file cannot be written.
|
/// Will be raised when a file cannot be written.
|
||||||
/// - 16: @LIT{cannot overwrite file}
|
/// - 16: @LIT{cannot overwrite file}
|
||||||
/// Will be raised when an attempt is made to overwrite an existing file.
|
/// Will be raised when an attempt is made to overwrite an existing file.
|
||||||
|
/// - 17: @LIT{type error}
|
||||||
|
/// Will be raised when a type error is unencountered.
|
||||||
/// - 400: @LIT{bad parameter}
|
/// - 400: @LIT{bad parameter}
|
||||||
/// Will be raised when the HTTP request does not fulfill the requirements.
|
/// Will be raised when the HTTP request does not fulfill the requirements.
|
||||||
/// - 403: @LIT{forbidden}
|
/// - 403: @LIT{forbidden}
|
||||||
|
@ -565,6 +567,16 @@ void TRI_InitialiseErrorMessages (void);
|
||||||
|
|
||||||
#define TRI_ERROR_CANNOT_OVERWRITE_FILE (16)
|
#define TRI_ERROR_CANNOT_OVERWRITE_FILE (16)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief 17: ERROR_TYPE_ERROR
|
||||||
|
///
|
||||||
|
/// type error
|
||||||
|
///
|
||||||
|
/// Will be raised when a type error is unencountered.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define TRI_ERROR_TYPE_ERROR (17)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief 400: ERROR_HTTP_BAD_PARAMETER
|
/// @brief 400: ERROR_HTTP_BAD_PARAMETER
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue