dashboardjavacloudcoapiotiot-analyticsiot-platformiot-solutionskafkalwm2mmicroservicesmiddlewaremqttnettyplatformsnmpthingsboardvisualizationwebsocketswidgets
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.4 KiB
102 lines
2.4 KiB
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.YAMLWarning = exports.YAMLSyntaxError = exports.YAMLSemanticError = exports.YAMLReferenceError = exports.YAMLError = void 0;
|
|
|
|
var _Node = _interopRequireDefault(require("./cst/Node"));
|
|
|
|
var _sourceUtils = require("./cst/source-utils");
|
|
|
|
var _Range = _interopRequireDefault(require("./cst/Range"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
class YAMLError extends Error {
|
|
constructor(name, source, message) {
|
|
if (!message || !(source instanceof _Node.default)) throw new Error(`Invalid arguments for new ${name}`);
|
|
super();
|
|
this.name = name;
|
|
this.message = message;
|
|
this.source = source;
|
|
}
|
|
|
|
makePretty() {
|
|
if (!this.source) return;
|
|
this.nodeType = this.source.type;
|
|
const cst = this.source.context && this.source.context.root;
|
|
|
|
if (typeof this.offset === 'number') {
|
|
this.range = new _Range.default(this.offset, this.offset + 1);
|
|
const start = cst && (0, _sourceUtils.getLinePos)(this.offset, cst);
|
|
|
|
if (start) {
|
|
const end = {
|
|
line: start.line,
|
|
col: start.col + 1
|
|
};
|
|
this.linePos = {
|
|
start,
|
|
end
|
|
};
|
|
}
|
|
|
|
delete this.offset;
|
|
} else {
|
|
this.range = this.source.range;
|
|
this.linePos = this.source.rangeAsLinePos;
|
|
}
|
|
|
|
if (this.linePos) {
|
|
const {
|
|
line,
|
|
col
|
|
} = this.linePos.start;
|
|
this.message += ` at line ${line}, column ${col}`;
|
|
const ctx = cst && (0, _sourceUtils.getPrettyContext)(this.linePos, cst);
|
|
if (ctx) this.message += `:\n\n${ctx}\n`;
|
|
}
|
|
|
|
delete this.source;
|
|
}
|
|
|
|
}
|
|
|
|
exports.YAMLError = YAMLError;
|
|
|
|
class YAMLReferenceError extends YAMLError {
|
|
constructor(source, message) {
|
|
super('YAMLReferenceError', source, message);
|
|
}
|
|
|
|
}
|
|
|
|
exports.YAMLReferenceError = YAMLReferenceError;
|
|
|
|
class YAMLSemanticError extends YAMLError {
|
|
constructor(source, message) {
|
|
super('YAMLSemanticError', source, message);
|
|
}
|
|
|
|
}
|
|
|
|
exports.YAMLSemanticError = YAMLSemanticError;
|
|
|
|
class YAMLSyntaxError extends YAMLError {
|
|
constructor(source, message) {
|
|
super('YAMLSyntaxError', source, message);
|
|
}
|
|
|
|
}
|
|
|
|
exports.YAMLSyntaxError = YAMLSyntaxError;
|
|
|
|
class YAMLWarning extends YAMLError {
|
|
constructor(source, message) {
|
|
super('YAMLWarning', source, message);
|
|
}
|
|
|
|
}
|
|
|
|
exports.YAMLWarning = YAMLWarning;
|