1
0
Fork 0

Setup and teardown of foxx apps and foxx dev apps should now print their errors properly

This commit is contained in:
Michael Hackstein 2014-12-18 10:46:54 +01:00
parent 59d406dc62
commit e23b81779d
2 changed files with 47 additions and 71 deletions

View File

@ -171,8 +171,8 @@ function checkManifest (filename, mf) {
if (failed) {
throw new ArangoError({
errorNum: errors.MANIFEST_FILE_ATTRIBUTE_MISSING.code,
errorMessage: errors.MANIFEST_FILE_ATTRIBUTE_MISSING.message
errorNum: errors.ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING.code,
errorMessage: errors.ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING.message
});
}
@ -1596,80 +1596,55 @@ exports.developmentRoutes = function () {
for (j = 0; j < files.length; ++j) {
m = fs.join(root, files[j], "manifest.json");
mf = validateManifestFile(m);
if (mf !== undefined) {
if (fs.exists(m)) {
try {
mf = JSON.parse(fs.read(m));
} catch (err) {
console.errorLines(
"Cannot parse app manifest '%s': %s", m, String(err));
continue;
}
try {
checkManifest(m, mf);
} catch (err) {
console.errorLines(
"Manifest file '%s' invalid: %s", m, String(err));
continue;
}
appId = "dev:" + mf.name + ":" + files[j];
mount = "/dev/" + files[j];
options = {
collectionPrefix : prefixFromMount(mount)
};
app = createApp(appId, options, mf.name, m);
if (app !== undefined) {
try {
setupApp(app, mount, options.collectionPrefix);
} catch (err) {
console.errorLines(
"Setup of App '%s' with manifest '%s' failed: %s", mf.name, m, String(err));
continue;
}
try {
app = module.createApp(appId, options);
} catch (err) {
console.errorLines(
"Failed to create App '%s' with manifest '%s': %s", mf.name, m, String(err));
continue;
try {
r = routingAalApp(app, mount, options);
} catch (err) {
console.errorLines(
"Unable to properly route the App '%s': %s", mf.name, String(err.stack || err)
);
continue;
}
if (r === null) {
console.errorLines("Cannot compute the routing table for Foxx application '%s'" , app._id);
continue;
}
routes.push(r);
var desc = {
_id: "dev/" + app._id,
_key: app._id,
type: "mount",
app: app._id,
name: app._name,
description: app._manifest.description,
repository: app._manifest.repository,
license: app._manifest.license,
author: app._manifest.author,
mount: mount,
active: true,
collectionPrefix: options.collectionPrefix,
isSystem: app._manifest.isSystem || false,
options: options
};
mounts.push(desc);
}
if (app === null) {
console.errorLines(
"Cannot find application '%s'", appId);
continue;
}
try {
// TODO check
setupApp(app, mount, options.collectionPrefix);
} catch (err) {
console.errorLines(
"Setup of App '%s' with manifest '%s' failed: %s", m, String(err));
continue;
}
try {
r = routingAalApp(app, mount, options);
} catch (err) {
console.errorLines(
"Unable to properly route the App '%s': %s", mf.name, String(err.stack || err)
);
continue;
}
if (r === null) {
console.errorLines("Cannot compute the routing table for Foxx application '%s'" , app._id);
continue;
}
routes.push(r);
var desc = {
_id: "dev/" + app._id,
_key: app._id,
type: "mount",
app: app._id,
name: app._name,
description: app._manifest.description,
repository: app._manifest.repository,
license: app._manifest.license,
author: app._manifest.author,
mount: mount,
active: true,
collectionPrefix: options.collectionPrefix,
isSystem: app._manifest.isSystem || false,
options: options
};
mounts.push(desc);
}
}

View File

@ -348,9 +348,10 @@ SIMPLE_CLIENT_COULD_NOT_READ,2003,"could not read from server","Will be raised w
## Foxx Manager
################################################################################
MALFORMED_MANIFEST_FILE,3000,"malformed manifest file","The Manifest file is malformed. It is not in a valid JSON format."
MANIFEST_FILE_ATTRIBUTE_MISSING,3001,"missing manifest attribute","The Manifest file is incomplete. A required attribute is missing."
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."
################################################################################
## results, which are not errors