mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:arangodb/arangodb into devel
This commit is contained in:
commit
8f1e79e5dc
|
@ -280,12 +280,7 @@ actions.defineHttp({
|
|||
var name = body.name;
|
||||
var mount = body.mount;
|
||||
var options = body.options;
|
||||
try {
|
||||
var result = foxxManager.runScript(name, mount, options);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw e.cause || e;
|
||||
}
|
||||
return foxxManager.runScript(name, mount, options);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -95,7 +95,9 @@ exports.checkRequestResult = function (requestResult) {
|
|||
throw new TypeError(requestResult.errorMessage);
|
||||
}
|
||||
|
||||
throw new ArangoError(requestResult);
|
||||
const error = new ArangoError(requestResult);
|
||||
error.message = requestResult.message;
|
||||
throw error;
|
||||
}
|
||||
|
||||
// remove the property from the original object
|
||||
|
|
|
@ -701,13 +701,7 @@ var run = function (args) {
|
|||
return 0;
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof ArangoError) {
|
||||
printf("%s\n", err.errorMessage);
|
||||
}
|
||||
else {
|
||||
printf("%s\n", err.message);
|
||||
}
|
||||
|
||||
arangodb.print(String(err));
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -411,9 +411,11 @@ Module._load = function(request, parent, isMain) {
|
|||
if (match) {
|
||||
dbModule = Module._resolveDbModule(match[3]);
|
||||
if (!dbModule) {
|
||||
var err = new Error("Cannot find module '" + request + "'");
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
throw new internal.ArangoError({
|
||||
errorNum: internal.errors.ERROR_MODULE_NOT_FOUND.code,
|
||||
errorMessage: internal.errors.ERROR_MODULE_NOT_FOUND.message
|
||||
+ '\nFile: ' + request
|
||||
});
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
@ -495,9 +497,11 @@ Module._resolveFilename = function(request, parent) {
|
|||
// look up the filename first, since that's the cache key.
|
||||
var filename = Module._findPath(request, paths);
|
||||
if (!filename) {
|
||||
var err = new Error("Cannot find module '" + request + "'");
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
throw new internal.ArangoError({
|
||||
errorNum: internal.errors.ERROR_MODULE_NOT_FOUND.code,
|
||||
errorMessage: internal.errors.ERROR_MODULE_NOT_FOUND.message
|
||||
+ '\nFile: ' + request
|
||||
});
|
||||
}
|
||||
return filename;
|
||||
};
|
||||
|
@ -511,7 +515,23 @@ Module.prototype.load = function(filename) {
|
|||
|
||||
var extension = path.extname(filename) || '.js';
|
||||
if (!Module._extensions[extension]) extension = '.js';
|
||||
Module._extensions[extension](this, filename);
|
||||
|
||||
try {
|
||||
Module._extensions[extension](this, filename);
|
||||
} catch (e) {
|
||||
if (e.errorNum !== internal.errors.ERROR_MODULE_FAILURE.code) {
|
||||
const error = new internal.ArangoError({
|
||||
errorNum: internal.errors.ERROR_MODULE_FAILURE.code,
|
||||
errorMessage: internal.errors.ERROR_MODULE_FAILURE.message
|
||||
+ '\nFile: ' + filename
|
||||
+ '\nCause: ' + e
|
||||
});
|
||||
error.cause = e;
|
||||
throw error;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
this.loaded = true;
|
||||
};
|
||||
|
||||
|
@ -545,15 +565,6 @@ Module.prototype._compile = function(content, filename) {
|
|||
content = this.preprocess(content, filename);
|
||||
}
|
||||
|
||||
// test for parse errors first and fail early if a parse error detected
|
||||
if (!internal.parse(content, filename)) {
|
||||
throw new internal.ArangoError({
|
||||
errorNum: internal.errors.ERROR_MODULE_SYNTAX_ERROR.code,
|
||||
errorMessage: internal.errors.ERROR_MODULE_SYNTAX_ERROR.message
|
||||
+ '\nFile: ' + filename
|
||||
});
|
||||
}
|
||||
|
||||
this.filename = filename;
|
||||
|
||||
var args = this.context;
|
||||
|
@ -561,38 +572,15 @@ Module.prototype._compile = function(content, filename) {
|
|||
// Do not use Function constructor or line numbers will be wrong
|
||||
var wrapper = `(function (${keys.join(', ')}) {${content}\n})`;
|
||||
|
||||
var fn;
|
||||
try {
|
||||
fn = internal.executeScript(wrapper, undefined, filename);
|
||||
} catch (e) {
|
||||
console.errorLines(e.stack || String(e));
|
||||
let err = new internal.ArangoError({
|
||||
errorNum: internal.errors.ERROR_SYNTAX_ERROR_IN_SCRIPT.code,
|
||||
errorMessage: internal.errors.ERROR_SYNTAX_ERROR_IN_SCRIPT.message
|
||||
+ '\nFile: ' + filename
|
||||
});
|
||||
err.cause = e;
|
||||
throw err;
|
||||
}
|
||||
var fn = internal.executeScript(wrapper, undefined, filename);
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('Expected internal.executeScript to return a function, not ' + typeof fn);
|
||||
throw new TypeError(`Expected internal.executeScript to return a function, not ${typeof fn}`);
|
||||
}
|
||||
|
||||
try {
|
||||
fn.apply(args.exports, keys.map(function (key) {
|
||||
return args[key];
|
||||
}));
|
||||
} catch (e) {
|
||||
console.errorLines(e.stack || String(e));
|
||||
let err = new internal.ArangoError({
|
||||
errorNum: internal.errors.ERROR_MODULE_FAILURE.code,
|
||||
errorMessage: internal.errors.ERROR_MODULE_FAILURE.message
|
||||
+ '\nFile: ' + filename
|
||||
});
|
||||
err.cause = e;
|
||||
throw err;
|
||||
}
|
||||
fn.apply(args.exports, keys.map(function (key) {
|
||||
return args[key];
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,22 +49,27 @@ if (global.ArangoError) {
|
|||
this.errorNum = error.errorNum;
|
||||
this.errorMessage = error.errorMessage;
|
||||
}
|
||||
|
||||
this.message = this.toString();
|
||||
};
|
||||
|
||||
exports.ArangoError.prototype = new Error();
|
||||
}
|
||||
|
||||
Object.defineProperty(exports.ArangoError.prototype, 'message', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this.errorMessage;
|
||||
}
|
||||
});
|
||||
|
||||
exports.ArangoError.prototype.name = 'ArangoError';
|
||||
|
||||
exports.ArangoError.prototype._PRINT = function(context) {
|
||||
context.output += this.toString();
|
||||
context.output += '[' + this.toString() + ']';
|
||||
};
|
||||
|
||||
exports.ArangoError.prototype.toString = function() {
|
||||
var errorNum = this.errorNum;
|
||||
var errorMessage = this.errorMessage || this.message;
|
||||
|
||||
return '[ArangoError ' + errorNum + ': ' + errorMessage + ']';
|
||||
return `${this.name} ${this.errorNum}: ${this.message}`;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const Module = require('module');
|
||||
const ArangoError = require('@arangodb').ArangoError;
|
||||
const errors = require('@arangodb').errors;
|
||||
const runTests = require('@arangodb/mocha').run;
|
||||
const colors = require('internal').COLORS;
|
||||
|
||||
|
@ -200,17 +198,6 @@ function run(filename, context) {
|
|||
});
|
||||
}
|
||||
|
||||
try {
|
||||
module.load(filename);
|
||||
return module.exports;
|
||||
} catch(e) {
|
||||
const err = new ArangoError({
|
||||
errorNum: errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code,
|
||||
errorMessage: errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.message
|
||||
+ '\nFile: ' + filename
|
||||
});
|
||||
err.stack = e.stack;
|
||||
err.cause = e;
|
||||
throw err;
|
||||
}
|
||||
module.load(filename);
|
||||
return module.exports;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ function ErrorsSuite () {
|
|||
fail();
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual("[ArangoError " + e.code + ": " + e.message + "]", err.toString());
|
||||
assertEqual("ArangoError " + e.code + ": " + e.message, err.toString());
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -174,14 +174,13 @@ function ErrorsSuite () {
|
|||
fail();
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual("[ArangoError " + e.code + ": " + e.message + ": did not find document]", err.toString());
|
||||
assertEqual("ArangoError " + e.code + ": " + e.message + ": did not find document", err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief executes the test suite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -102,92 +102,138 @@ describe('Foxx Manager install', function() {
|
|||
it('with malformed controller file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-controller-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code);
|
||||
});
|
||||
|
||||
it('with malformed controller path', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-controller-name'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_INVALID_APPLICATION_MANIFEST.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause').that.is.an.instanceof(SyntaxError);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with malformed controller path', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-controller-path'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause') .that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with broken controller file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'broken-controller-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause');
|
||||
expect(err.cause).not.to.be.an.instanceof(SyntaxError);
|
||||
expect(err.cause).not.to.be.an.instanceof(ArangoError);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with broken exports file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'broken-exports-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause');
|
||||
expect(err.cause).not.to.be.an.instanceof(SyntaxError);
|
||||
expect(err.cause).not.to.be.an.instanceof(ArangoError);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with broken setup file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'broken-setup-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause');
|
||||
expect(err.cause).not.to.be.an.instanceof(SyntaxError);
|
||||
expect(err.cause).not.to.be.an.instanceof(ArangoError);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with malformed exports file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-exports-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause').that.is.an.instanceof(SyntaxError);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with malformed exports path', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-exports-path'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with malformed setup file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-setup-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause').that.is.an.instanceof(SyntaxError);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with malformed setup path', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'malformed-setup-path'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with missing controller file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'missing-controller-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with missing exports file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'missing-exports-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
it('with missing setup file', function() {
|
||||
expect(function () {
|
||||
FoxxManager.install(fs.join(basePath, 'missing-setup-file'), '/unittest/broken');
|
||||
}).to.throw(ArangoError)
|
||||
.with.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
}).to.throw(ArangoError).that.satisfies(function (err) {
|
||||
expect(err).to.have.property('errorNum', errors.ERROR_MODULE_FAILURE.code);
|
||||
expect(err).to.have.property('cause')
|
||||
.that.is.an.instanceof(ArangoError)
|
||||
.with.a.property('errorNum', errors.ERROR_SYS_ERROR.code);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ function createCallbackFromActionCallbackString (callback, parentModule, route)
|
|||
try {
|
||||
actionModule._compile(`module.exports = ${callback}`, route.name);
|
||||
} catch (e) {
|
||||
console.errorLines(e.stack);
|
||||
return notImplementedFunction(route, util.format(
|
||||
"could not generate callback for '%s'",
|
||||
callback
|
||||
|
|
|
@ -401,32 +401,35 @@ function checkManifest(filename, manifest) {
|
|||
/// All errors are handled including file not found. Returns undefined if manifest is invalid
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function validateManifestFile(file) {
|
||||
function validateManifestFile(filename) {
|
||||
var mf, msg;
|
||||
if (!fs.exists(file)) {
|
||||
msg = `Cannot find manifest file "${file}"`;
|
||||
console.errorLines(msg);
|
||||
if (!fs.exists(filename)) {
|
||||
msg = `Cannot find manifest file "${filename}"`;
|
||||
throwFileNotFound(msg);
|
||||
}
|
||||
try {
|
||||
mf = JSON.parse(fs.read(file));
|
||||
} catch (err) {
|
||||
let details = String(err.stack || err);
|
||||
msg = `Cannot parse app manifest "${file}": ${details}`;
|
||||
console.errorLines(msg);
|
||||
throw new ArangoError({
|
||||
mf = JSON.parse(fs.read(filename));
|
||||
} catch (e) {
|
||||
const error = ArangoError({
|
||||
errorNum: errors.ERROR_MALFORMED_MANIFEST_FILE.code,
|
||||
errorMessage: msg
|
||||
errorMessage: errors.ERROR_MALFORMED_MANIFEST_FILE.message
|
||||
+ '\nFile: ' + filename
|
||||
+ '\nCause: ' + e
|
||||
});
|
||||
error.cause = e;
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
checkManifest(file, mf);
|
||||
} catch (err) {
|
||||
console.errorLines(`Manifest file "${file}" is invalid:\n${err.errorMessage}`);
|
||||
if (err.stack) {
|
||||
console.errorLines(err.stack);
|
||||
}
|
||||
throw err;
|
||||
checkManifest(filename, mf);
|
||||
} catch (e) {
|
||||
const error = ArangoError({
|
||||
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
|
||||
errorMessage: errors.ERROR_INVALID_APPLICATION_MANIFEST.message
|
||||
+ '\nFile: ' + filename
|
||||
+ '\nCause: ' + e
|
||||
});
|
||||
error.cause = e;
|
||||
throw error;
|
||||
}
|
||||
return mf;
|
||||
}
|
||||
|
@ -485,24 +488,14 @@ function computeAppPath(mount) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function executeAppScript(scriptName, app, argv) {
|
||||
var readableName = utils.getReadableName(scriptName);
|
||||
var scripts = app.manifest.scripts;
|
||||
|
||||
// Only run setup/teardown scripts if they exist
|
||||
if (scripts[scriptName] || (scriptName !== 'setup' && scriptName !== 'teardown')) {
|
||||
try {
|
||||
return app.run(scripts[scriptName], {
|
||||
appContext: {
|
||||
argv: argv ? (Array.isArray(argv) ? argv : [argv]) : []
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
if (!(e.cause || e).statusCode) {
|
||||
let details = String((e.cause || e).stack || e.cause || e);
|
||||
console.errorLines(`Running script "${readableName}" not possible for mount "${app.mount}":\n${details}`);
|
||||
return app.run(scripts[scriptName], {
|
||||
appContext: {
|
||||
argv: argv ? (Array.isArray(argv) ? argv : [argv]) : []
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,10 +608,10 @@ function installAppFromGenerator(targetPath, options) {
|
|||
invalidOptions.push('options.collectionNames has to be an array.');
|
||||
}
|
||||
if (invalidOptions.length > 0) {
|
||||
console.log(invalidOptions);
|
||||
throw new ArangoError({
|
||||
errorNum: errors.ERROR_INVALID_FOXX_OPTIONS.code,
|
||||
errorMessage: JSON.stringify(invalidOptions, undefined, 2)
|
||||
errorMessage: errors.ERROR_INVALID_FOXX_OPTIONS.message
|
||||
+ '\nOptions: ' + JSON.stringify(invalidOptions, undefined, 2)
|
||||
});
|
||||
}
|
||||
options.path = targetPath;
|
||||
|
@ -973,8 +966,6 @@ function _validateApp(appInfo) {
|
|||
routeApp(tmp, true);
|
||||
exportApp(tmp);
|
||||
}
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
fs.removeDirectoryRecursive(tempPath, true);
|
||||
}
|
||||
|
@ -1040,20 +1031,6 @@ function _install(appInfo, mount, options, runSetup) {
|
|||
} catch (err) {
|
||||
console.errorLines(err.stack);
|
||||
}
|
||||
if (e instanceof ArangoError) {
|
||||
if (e.errorNum === errors.ERROR_MODULE_SYNTAX_ERROR.code) {
|
||||
throw _.extend(new ArangoError({
|
||||
errorNum: errors.ERROR_SYNTAX_ERROR_IN_SCRIPT.code,
|
||||
errorMessage: errors.ERROR_SYNTAX_ERROR_IN_SCRIPT.message
|
||||
}), {stack: e.stack});
|
||||
}
|
||||
if (e.errorNum === errors.ERROR_MODULE_FAILURE.code) {
|
||||
throw _.extend(new ArangoError({
|
||||
errorNum: errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code,
|
||||
errorMessage: errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.message
|
||||
}), {stack: e.stack});
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return app;
|
||||
|
@ -1142,12 +1119,6 @@ function _uninstall(mount, options) {
|
|||
}
|
||||
var collection = utils.getStorage();
|
||||
var targetPath = computeAppPath(mount, true);
|
||||
if (!fs.exists(targetPath) && !options.force) {
|
||||
throw new ArangoError({
|
||||
errorNum: errors.ERROR_NO_FOXX_FOUND.code,
|
||||
errorMessage: errors.ERROR_NO_FOXX_FOUND.message
|
||||
});
|
||||
}
|
||||
delete appCache[dbname][mount];
|
||||
if (!options.__clusterDistribution) {
|
||||
try {
|
||||
|
|
|
@ -596,10 +596,7 @@ var routeApp = function (app, isInstallProcess) {
|
|||
// return the new routes
|
||||
return routes;
|
||||
} catch (e) {
|
||||
console.error("Cannot compute Foxx application routes: %s", String(e));
|
||||
if (e.hasOwnProperty("stack")) {
|
||||
console.errorLines(e.stack);
|
||||
}
|
||||
console.errorLines(`Cannot compute Foxx application routes:\n${e.stack}`);
|
||||
if (isInstallProcess) {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const _ = require('lodash');
|
||||
const ArangoError = require('@arangodb').ArangoError;
|
||||
const errors = require('@arangodb').errors;
|
||||
const internal = require('internal');
|
||||
const assert = require('assert');
|
||||
const Module = require('module');
|
||||
|
@ -402,23 +400,8 @@ class FoxxService {
|
|||
});
|
||||
}
|
||||
|
||||
try {
|
||||
module.load(filename);
|
||||
return module.exports;
|
||||
} catch(e) {
|
||||
if (e instanceof ArangoError) {
|
||||
e.errorMessage += "\n(app relative include paths not supported anymore) \nFile: " + filename;
|
||||
throw e;
|
||||
}
|
||||
var err = new ArangoError({
|
||||
errorNum: errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.code,
|
||||
errorMessage: errors.ERROR_FAILED_TO_EXECUTE_SCRIPT.message
|
||||
+ '\nFile: ' + filename
|
||||
});
|
||||
err.stack = e.stack;
|
||||
err.cause = e;
|
||||
throw err;
|
||||
}
|
||||
module.load(filename);
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
get exports() {
|
||||
|
|
|
@ -358,13 +358,8 @@ SIMPLE_CLIENT_COULD_NOT_READ,2003,"could not read from server","Will be raised w
|
|||
|
||||
ERROR_MALFORMED_MANIFEST_FILE,3000,"malformed manifest file","The manifest file is malformed. It is not in a valid JSON format."
|
||||
ERROR_INVALID_APPLICATION_MANIFEST,3001,"manifest file is invalid","The manifest file of this application is invalid."
|
||||
ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING,3002,"missing manifest attribute","The manifest file is incomplete. A required attribute is missing."
|
||||
ERROR_CANNOT_EXTRACT_APPLICATION_ROOT,3003,"unable to extract app root path","The root path of the application could not be found."
|
||||
ERROR_INVALID_FOXX_OPTIONS,3004,"invalid foxx options","The options used to configure the foxx are invalid."
|
||||
ERROR_FAILED_TO_EXECUTE_SCRIPT,3005,"failed to execute script","The script provided contains errors."
|
||||
ERROR_SYNTAX_ERROR_IN_SCRIPT,3006,"syntax error in script"," contains a syntax error: "
|
||||
ERROR_INVALID_MOUNTPOINT,3007,"mountpoint is invalid","mountpoint is invalid"
|
||||
ERROR_NO_FOXX_FOUND,3008,"No foxx found at this location","No foxx found at this location"
|
||||
ERROR_APP_NOT_FOUND,3009,"App not found","No app found at this mountpoint"
|
||||
ERROR_APP_NEEDS_CONFIGURATION,3010,"App not configured","The app has to be configured before it can be used"
|
||||
|
||||
|
@ -373,18 +368,7 @@ ERROR_APP_NEEDS_CONFIGURATION,3010,"App not configured","The app has to be confi
|
|||
################################################################################
|
||||
|
||||
ERROR_MODULE_NOT_FOUND,3100,"cannot locate module","The module path could not be resolved."
|
||||
ERROR_MODULE_SYNTAX_ERROR,3101,"syntax error in module","The module could not be parsed because of a syntax error."
|
||||
ERROR_MODULE_BAD_WRAPPER,3102,"failed to wrap module","The module wrapper could not be generated. This may indicate a problem with some of the names of the module's context variables."
|
||||
ERROR_MODULE_FAILURE,3103,"failed to invoke module","Failed to invoke the module in its context."
|
||||
ERROR_MODULE_UNKNOWN_FILE_TYPE,3110,"unknown file type","The module path resolves to a file of an unknown type."
|
||||
ERROR_MODULE_PATH_MUST_BE_ABSOLUTE,3111,"path must be absolute","The module path must be absolute."
|
||||
ERROR_MODULE_CAN_NOT_ESCAPE,3112,"cannot use '..' to escape top-level-directory","The relative module path can not escape the module's top-level directory."
|
||||
ERROR_MODULE_DRIVE_LETTER,3113,"drive local path is not supported","The module path contains a Windows drive letter, which is not supported."
|
||||
ERROR_MODULE_BAD_MODULE_ORIGIN,3120,"corrupted module origin","The module origin is invalid."
|
||||
ERROR_MODULE_BAD_PACKAGE_ORIGIN,3121,"corrupted package origin","The package origin is invalid."
|
||||
ERROR_MODULE_DOCUMENT_IS_EMPTY,3125,"no content","The module resolves to a document which is empty or malformed."
|
||||
ERROR_MODULE_MAIN_NOT_READABLE,3130,"cannot read main file","The module's main file is not readable."
|
||||
ERROR_MODULE_MAIN_NOT_JS,3131,"main file is not of type 'js'","The module's main file is not a JavaScript file."
|
||||
|
||||
################################################################################
|
||||
## results, which are not errors
|
||||
|
@ -393,12 +377,6 @@ ERROR_MODULE_MAIN_NOT_JS,3131,"main file is not of type 'js'","The module's main
|
|||
RESULT_ELEMENT_EXISTS,10000,"element not inserted into structure, because it already exists","Will be returned if the element was not insert because it already exists."
|
||||
RESULT_ELEMENT_NOT_FOUND,10001,"element not found in structure","Will be returned if the element was not found in the structure."
|
||||
|
||||
################################################################################
|
||||
## foxx app update via github
|
||||
################################################################################
|
||||
|
||||
ERROR_APP_ALREADY_EXISTS,20000,"newest version of app already installed","newest version of app already installed"
|
||||
|
||||
################################################################################
|
||||
## dispatcher errors
|
||||
################################################################################
|
||||
|
|
|
@ -3810,12 +3810,6 @@ void TRI_LogV8Exception(v8::Isolate* isolate, v8::TryCatch* tryCatch) {
|
|||
|
||||
LOG(ERR) << "!" << l.c_str();
|
||||
}
|
||||
|
||||
TRI_Utf8ValueNFC stacktrace(TRI_UNKNOWN_MEM_ZONE, tryCatch->StackTrace());
|
||||
|
||||
if (*stacktrace && stacktrace.length() > 0) {
|
||||
LOG(ERR) << "stacktrace: " << *stacktrace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue