@microsoft.azure/autorest.incubator
Version:
AutoRest incubator project
68 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const autorest_extension_base_1 = require("@microsoft.azure/autorest-extension-base");
class ModelState {
constructor(service, model, documentName, currentPath = new Array()) {
this.service = service;
this.model = model;
this.documentName = documentName;
this.currentPath = currentPath;
this.errorCount = 0;
}
path(...childPath) {
return new ModelState(this.service, this.model, this.documentName, [...this.currentPath, ...childPath]);
}
checkpoint() {
if (this.errorCount > 0) {
throw new Error();
}
}
msg(channel, message, key, details) {
this.service.Message({
Channel: channel,
Key: key,
Source: [
{
document: this.documentName,
Position: {
path: this.currentPath
}
}
],
Text: message,
Details: details
});
}
warning(message, key, details) {
this.msg(autorest_extension_base_1.Channel.Warning, message, key, details);
}
hint(message, key, details) {
this.msg(autorest_extension_base_1.Channel.Hint, message, key, details);
}
error(message, key, details) {
this.errorCount++;
this.msg(autorest_extension_base_1.Channel.Error, message, key, details);
}
fatal(message, key, details) {
this.errorCount++;
this.msg(autorest_extension_base_1.Channel.Fatal, message, key, details);
}
output(channel, message, details) {
this.service.Message({
Channel: channel,
Text: message,
Details: details
});
}
debug(message, details) {
this.output(autorest_extension_base_1.Channel.Debug, message, details);
}
verbose(message, details) {
this.output(autorest_extension_base_1.Channel.Verbose, message, details);
}
log(message, details) {
this.output(autorest_extension_base_1.Channel.Information, message, details);
}
}
exports.ModelState = ModelState;
//# sourceMappingURL=model-state.js.map