1
0
Fork 0

Whenever there is an error during launch of the application it is now returned by the route

This commit is contained in:
Michael Hackstein 2015-01-22 15:29:33 +01:00
parent c988add0b8
commit 3e39372f0d
2 changed files with 48 additions and 35 deletions

View File

@ -108,10 +108,22 @@
/// @brief ArangoApp constructor
////////////////////////////////////////////////////////////////////////////////
var ArangoApp = function (config) {
this._manifest = config.manifest;
this._name = config.manifest.name;
this._version = config.manifest.version;
var ArangoApp = function (config) {
if (config.hasOwnProperty("error")) {
this._error = config.error;
this._isBroken = true;
}
if (!config.hasOwnProperty("manifest")) {
// Parse Error in manifest.
this._manifest = {
name: "unknown",
version: "error"
};
} else {
this._manifest = config.manifest;
}
this._name = this._manifest.name;
this._version = this._manifest.version;
this._root = config.root;
this._path = config.path;
this._options = config.options;
@ -159,6 +171,9 @@ var ArangoApp = function (config) {
isSystem: this._isSystem,
isDevelopment: this._isDevelopment
};
if (this.hasOwnProperty("_error")) {
json.error = this._error;
}
if (this._manifest.hasOwnProperty("author")) {
json.author = this._manifest.author;
}
@ -207,6 +222,9 @@ var ArangoApp = function (config) {
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.configure = function(config) {
if (!this._manifest.hasOwnProperty("configuration")) {
return [];
}
var expected = this._manifest.configuration;
var attr;
var type;

View File

@ -1392,23 +1392,25 @@ exports.initializeFoxx = function () {
////////////////////////////////////////////////////////////////////////////////
var validateManifestFile = function(file) {
var mf;
var mf, msg;
if (!fs.exists(file)) {
return;
msg = "Cannot find manifest file '" + file + "'";
console.errorLines(msg);
throwFileNotFound(msg);
}
try {
mf = JSON.parse(fs.read(file));
} catch (err) {
console.errorLines(
"Cannot parse app manifest '%s': %s", file, String(err));
return;
msg = "Cannot parse app manifest '" + file + "': " + String(err);
console.errorLines(msg);
throw msg;
}
try {
checkManifest(file, mf);
} catch (err) {
console.errorLines(
"Manifest file '%s' invalid: %s", file, String(err));
return;
msg = "Manifest file'" + file + "' is invalid: " + String(err);
console.errorLines(msg);
throw msg;
}
return mf;
};
@ -1483,28 +1485,27 @@ exports.initializeFoxx = function () {
/// @brief returns the app path and manifest
////////////////////////////////////////////////////////////////////////////////
var appConfig = function (mount, options) {
var appConfig = function (mount, options, activateDevelopment) {
var root = computeRootAppPath(mount);
var path = transformMountToPath(mount);
var file = fs.join(root, path, "manifest.json");
var manifest = validateManifestFile(file);
if (manifest === undefined) {
//TODO Error Handeling
return;
}
return {
var result = {
id: mount,
root: root,
path: path,
manifest: manifest,
options: options,
options: options || {},
mount: mount,
isSystem: isSystemMount(mount),
isDevelopment: false
isDevelopment: activateDevelopment || false
};
try {
result.manifest = validateManifestFile(file);
} catch(err) {
result.error = err;
require("console").log("Setting err");
}
return result;
};
////////////////////////////////////////////////////////////////////////////////
@ -1513,15 +1514,9 @@ exports.initializeFoxx = function () {
/// If the app is valid it will be added into the local app cache.
////////////////////////////////////////////////////////////////////////////////
var createApp = function(mount, options) {
var config = appConfig(mount);
config.options = options || {};
var createApp = function(mount, options, activateDevelopment) {
var config = appConfig(mount, options, activateDevelopment);
var app = new ArangoApp(config);
if (app === null) {
console.errorLines(
"Cannot find application '%s'", mount);
return;
}
appCache[mount] = app;
return app;
};
@ -1771,9 +1766,9 @@ exports.initializeFoxx = function () {
/// Does not check parameters and throws errors.
////////////////////////////////////////////////////////////////////////////////
var _scanFoxx = function(mount, options) {
var _scanFoxx = function(mount, options, activateDevelopment) {
delete appCache[mount];
var app = createApp(mount, options);
var app = createApp(mount, options, activateDevelopment);
utils.tmp_getStorage().save(app.toJSON());
return app;
};
@ -1810,7 +1805,7 @@ exports.initializeFoxx = function () {
utils.tmp_getStorage().removeByExample({mount: mount});
_scanFoxx(mount, old._options);
_scanFoxx(mount, old._options, old._isDevelopment);
};
////////////////////////////////////////////////////////////////////////////////