1
0
Fork 0

Started to tear appart the error handling in current devel mode. It will now print with a much closer relation to their source

This commit is contained in:
Michael Hackstein 2014-12-16 17:05:52 +01:00
parent 6feed25079
commit 8300296679
2 changed files with 77 additions and 43 deletions

View File

@ -171,8 +171,8 @@ function checkManifest (filename, mf) {
if (failed) {
throw new ArangoError({
errorNum: errors.ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING.code,
errorMessage: errors.ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING.message
errorNum: errors.MANIFEST_FILE_ATTRIBUTE_MISSING.code,
errorMessage: errors.MANIFEST_FILE_ATTRIBUTE_MISSING.message
});
}
@ -1596,55 +1596,80 @@ 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 {
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);
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;
}
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

@ -343,6 +343,15 @@ SIMPLE_CLIENT_COULD_NOT_CONNECT,2001,"could not connect to server","Will be rais
SIMPLE_CLIENT_COULD_NOT_WRITE,2002,"could not write to server","Will be raised when the client could not write data."
SIMPLE_CLIENT_COULD_NOT_READ,2003,"could not read from server","Will be raised when the client could not read data."
################################################################################
## 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."
################################################################################
## results, which are not errors
################################################################################