// Generated by CoffeeScript 1.12.5
var blueprintUtils, handleRuntimeProblems, logger,
hasProp = {}.hasOwnProperty;
blueprintUtils = require('./blueprint-utils');
logger = require('./logger');
handleRuntimeProblems = function(blueprintData) {
var annotation, apiDescriptionDocument, data, error, filename, i, len, log, message, ranges, ref, transactionName;
error = false;
for (filename in blueprintData) {
if (!hasProp.call(blueprintData, filename)) continue;
data = blueprintData[filename];
apiDescriptionDocument = data.raw;
ref = data.annotations;
for (i = 0, len = ref.length; i < len; i++) {
annotation = ref[i];
if (annotation.type === 'warning') {
log = logger.warn;
} else {
error = true;
log = logger.error;
}
if (annotation.component === 'apiDescriptionParser') {
ranges = blueprintUtils.warningLocationToRanges(annotation.location, apiDescriptionDocument);
message = "Parser " + annotation.type + " in file '" + filename + "': (" + annotation.type + " code " + annotation.code + ") " + annotation.message + " ";
if (ranges != null ? ranges.length : void 0) {
message += "on " + (blueprintUtils.rangesToLinesText(ranges));
}
log(message);
} else {
transactionName = [annotation.origin.resourceGroupName, annotation.origin.resourceName, annotation.origin.actionName].join(' > ');
log("Compilation " + annotation.type + " in file '" + filename + "': " + annotation.message + " (" + transactionName + ") ");
}
}
}
if (error) {
return new Error('Error when processing API description.');
}
};
module.exports = handleRuntimeProblems;
|