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 /// @brief ArangoApp constructor
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var ArangoApp = function (config) { var ArangoApp = function (config) {
this._manifest = config.manifest; if (config.hasOwnProperty("error")) {
this._name = config.manifest.name; this._error = config.error;
this._version = config.manifest.version; 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._root = config.root;
this._path = config.path; this._path = config.path;
this._options = config.options; this._options = config.options;
@ -159,6 +171,9 @@ var ArangoApp = function (config) {
isSystem: this._isSystem, isSystem: this._isSystem,
isDevelopment: this._isDevelopment isDevelopment: this._isDevelopment
}; };
if (this.hasOwnProperty("_error")) {
json.error = this._error;
}
if (this._manifest.hasOwnProperty("author")) { if (this._manifest.hasOwnProperty("author")) {
json.author = this._manifest.author; json.author = this._manifest.author;
} }
@ -207,6 +222,9 @@ var ArangoApp = function (config) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.configure = function(config) { ArangoApp.prototype.configure = function(config) {
if (!this._manifest.hasOwnProperty("configuration")) {
return [];
}
var expected = this._manifest.configuration; var expected = this._manifest.configuration;
var attr; var attr;
var type; var type;

View File

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