mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
* 'devel' of https://github.com/arangodb/arangodb: Lint No more need to wrap legacy errors in new Foxx HTTP API fixed initializing bug in dashboard ui at initial startup Correctly expose errors in old Foxx API Fix error expecations
This commit is contained in:
commit
55175386e7
|
@ -32,6 +32,7 @@ const actions = require('@arangodb/actions');
|
|||
const FoxxManager = require('@arangodb/foxx/manager');
|
||||
const request = require('@arangodb/request');
|
||||
const db = require('@arangodb').db;
|
||||
const ArangoError = require('@arangodb').ArangoError;
|
||||
const joinPath = require('path').join;
|
||||
const fs = require('fs');
|
||||
const fmu = require('@arangodb/foxx/manager-utils');
|
||||
|
@ -54,6 +55,9 @@ function proxyLocal (method, url, qs, body, headers = {}) {
|
|||
headers['content-length'] = body.length;
|
||||
}
|
||||
const res = request({method, url, qs, headers, body});
|
||||
if (res.json && res.json.errorNum) {
|
||||
throw new ArangoError(res.json);
|
||||
}
|
||||
res.throw();
|
||||
return res.body ? JSON.parse(res.body) : null;
|
||||
}
|
||||
|
|
|
@ -846,7 +846,15 @@
|
|||
}
|
||||
|
||||
var currentP = fmtNumber(self.history[self.server].residentSizePercent * 100, 2);
|
||||
var data = [prettyBytes(self.history[self.server].physicalMemory)];
|
||||
var data;
|
||||
|
||||
if (self.history[self.server].physicalMemory) {
|
||||
this.removeEmptyDataLabels();
|
||||
data = [prettyBytes(self.history[self.server].physicalMemory)];
|
||||
} else {
|
||||
this.addEmptyDataLabels();
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.history[self.server].residentSizeChart === undefined) {
|
||||
this.addEmptyDataLabels();
|
||||
|
@ -966,7 +974,8 @@
|
|||
|
||||
if (self.history[self.server].residentSizeChart === undefined) {
|
||||
self.addEmptyDataLabels();
|
||||
return;
|
||||
// initialize with 0 values then
|
||||
// return;
|
||||
} else {
|
||||
self.removeEmptyDataLabels();
|
||||
}
|
||||
|
@ -1041,9 +1050,15 @@
|
|||
return fmtNumber(((d * 100 * 100) / 100), 0) + '%';
|
||||
});
|
||||
|
||||
d3.select(selector)
|
||||
.datum(self.history[self.server][k])
|
||||
.call(self.distributionCharts[k]);
|
||||
if (self.history[self.server][k]) {
|
||||
d3.select(selector)
|
||||
.datum(self.history[self.server][k])
|
||||
.call(self.distributionCharts[k]);
|
||||
} else {
|
||||
d3.select(selector)
|
||||
.datum([])
|
||||
.call(self.distributionCharts[k]);
|
||||
}
|
||||
|
||||
nv.utils.windowResize(self.distributionCharts[k].update);
|
||||
|
||||
|
@ -1065,9 +1080,15 @@
|
|||
self.distributionCharts[k].height(dimensions.height);
|
||||
|
||||
// update data
|
||||
d3.select(selector)
|
||||
.datum(self.history[self.server][k])
|
||||
.call(self.distributionCharts[k]);
|
||||
if (self.history[self.server][k]) {
|
||||
d3.select(selector)
|
||||
.datum(self.history[self.server][k])
|
||||
.call(self.distributionCharts[k]);
|
||||
} else {
|
||||
d3.select(selector)
|
||||
.datum([])
|
||||
.call(self.distributionCharts[k]);
|
||||
}
|
||||
|
||||
// trigger resize
|
||||
nv.utils.windowResize(self.distributionCharts[k].update);
|
||||
|
|
|
@ -21,13 +21,6 @@ module.context.use(router);
|
|||
|
||||
const LDJSON = 'application/x-ldjson';
|
||||
|
||||
const legacyErrors = new Map([
|
||||
[errors.ERROR_SERVICE_INVALID_NAME.code, errors.ERROR_SERVICE_SOURCE_NOT_FOUND.code],
|
||||
[errors.ERROR_SERVICE_INVALID_MOUNT.code, errors.ERROR_INVALID_MOUNTPOINT.code],
|
||||
[errors.ERROR_SERVICE_DOWNLOAD_FAILED.code, errors.ERROR_SERVICE_SOURCE_ERROR.code],
|
||||
[errors.ERROR_SERVICE_UPLOAD_FAILED.code, errors.ERROR_SERVICE_SOURCE_ERROR.code]
|
||||
]);
|
||||
|
||||
const serviceToJson = (service) => (
|
||||
{
|
||||
mount: service.mount,
|
||||
|
@ -70,9 +63,8 @@ router.use((req, res, next) => {
|
|||
next();
|
||||
} catch (e) {
|
||||
if (e.isArangoError) {
|
||||
const errorNum = legacyErrors.get(e.errorNum) || e.errorNum;
|
||||
const status = actions.arangoErrorToHttpCode(errorNum);
|
||||
res.throw(status, e.errorMessage, {errorNum, cause: e});
|
||||
const status = actions.arangoErrorToHttpCode(e.errorNum);
|
||||
res.throw(status, e.errorMessage, {errorNum: e.errorNum, cause: e});
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -406,17 +406,6 @@ exports.stringPadding = function (str, len, pad, dir) {
|
|||
return str;
|
||||
};
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
// / @brief throws an error in case a download failed
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.throwDownloadError = function (msg) {
|
||||
throw new exports.ArangoError({
|
||||
errorNum: exports.errors.ERROR_SERVICE_DOWNLOAD_FAILED.code,
|
||||
errorMessage: exports.errors.ERROR_SERVICE_DOWNLOAD_FAILED.message + ': ' + String(msg)
|
||||
});
|
||||
};
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
// / @brief throws an error in case of missing file
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,12 +27,14 @@
|
|||
// / @author Copyright 2015, triAGENS GmbH, Cologne, Germany
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const dd = require('dedent');
|
||||
const arangodb = require('@arangodb');
|
||||
const plainServerVersion = arangodb.plainServerVersion;
|
||||
const db = arangodb.db;
|
||||
const errors = arangodb.errors;
|
||||
const ArangoError = arangodb.ArangoError;
|
||||
const download = require('internal').download;
|
||||
const fs = require('fs');
|
||||
const throwDownloadError = arangodb.throwDownloadError;
|
||||
const utils = require('@arangodb/foxx/manager-utils');
|
||||
const semver = require('semver');
|
||||
|
||||
|
@ -326,7 +328,14 @@ var update = function () {
|
|||
}, filename);
|
||||
|
||||
if (result.code < 200 || result.code > 299) {
|
||||
throwDownloadError("Github download from '" + url + "' failed with error code " + result.code);
|
||||
throw new ArangoError({
|
||||
errorNum: errors.ERROR_SERVICE_SOURCE_ERROR.code,
|
||||
errorMessage: dd`
|
||||
${errors.ERROR_SERVICE_SOURCE_ERROR.message}
|
||||
URL: ${url}
|
||||
Status Code: ${result.code}
|
||||
`
|
||||
});
|
||||
}
|
||||
|
||||
updateFishbowlFromZip(filename);
|
||||
|
|
|
@ -110,13 +110,8 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-controller-path'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause').that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_NOT_FOUND.code);
|
||||
expect(err).not.to.have.property('cause');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
@ -125,11 +120,10 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'broken-controller-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_SYNTAX_ERROR.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause');
|
||||
expect(err.cause).not.to.be.an.instanceof(SyntaxError);
|
||||
expect(err.cause).not.to.be.an.instanceof(ArangoError);
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(SyntaxError);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
|
@ -188,14 +182,8 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-exports-path'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_NOT_FOUND.code);
|
||||
expect(err).not.to.have.property('cause');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
@ -219,14 +207,8 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-setup-path'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_NOT_FOUND.code);
|
||||
expect(err).not.to.have.property('cause');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
@ -235,14 +217,8 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'missing-controller-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_NOT_FOUND.code);
|
||||
expect(err).not.to.have.property('cause');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
@ -251,14 +227,8 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'missing-exports-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_NOT_FOUND.code);
|
||||
expect(err).not.to.have.property('cause');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
@ -267,14 +237,8 @@ describe('Foxx Manager install', function () {
|
|||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'missing-setup-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
if (require('@arangodb').isServer) {
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
} else {
|
||||
expect(err).not.to.have.property('cause');
|
||||
}
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_NOT_FOUND.code);
|
||||
expect(err).not.to.have.property('cause');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue