@fnlb-project/stanza
Version:
Modern XMPP in the browser, with a JSON API
40 lines (39 loc) • 1.21 kB
JavaScript
export var JXTErrorCondition;
(function (JXTErrorCondition) {
JXTErrorCondition["NotWellFormed"] = "not-well-formed";
JXTErrorCondition["RestrictedXML"] = "restricted-xml";
JXTErrorCondition["AlreadyClosed"] = "already-closed";
JXTErrorCondition["UnknownRoot"] = "unknown-stream-root";
})(JXTErrorCondition || (JXTErrorCondition = {}));
export default class JXTError extends Error {
constructor(opts) {
super(opts.text);
this.isJXTError = true;
this.condition = opts.condition;
this.text = opts.text;
}
static notWellFormed(text) {
return new JXTError({
condition: JXTErrorCondition.NotWellFormed,
text
});
}
static restrictedXML(text) {
return new JXTError({
condition: JXTErrorCondition.RestrictedXML,
text
});
}
static alreadyClosed(text) {
return new JXTError({
condition: JXTErrorCondition.AlreadyClosed,
text
});
}
static unknownRoot(text) {
return new JXTError({
condition: JXTErrorCondition.UnknownRoot,
text
});
}
}