@prismatic-io/spectral
Version:
Utility library for building Prismatic connectors and code-native integrations
27 lines (26 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isConnectionError = exports.isSpectralError = exports.ConnectionError = exports.SpectralError = void 0;
class SpectralError extends Error {
constructor(message) {
super(message);
this.isSpectralError = true;
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
}
exports.SpectralError = SpectralError;
class ConnectionError extends SpectralError {
constructor(connection, message) {
super(message);
this.connection = connection;
}
}
exports.ConnectionError = ConnectionError;
const isSpectralError = (payload) => Boolean(payload &&
typeof payload === "object" &&
"isSpectralError" in payload &&
payload.isSpectralError === true);
exports.isSpectralError = isSpectralError;
const isConnectionError = (payload) => (0, exports.isSpectralError)(payload) && "connection" in payload;
exports.isConnectionError = isConnectionError;