UNPKG

livelists-node-js

Version:
37 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateChannelError = void 0; const BaseError_1 = require("../../common/BaseError"); const channel_1 = require("../../proto/channel"); var ErrorCodes; (function (ErrorCodes) { ErrorCodes["ChannelAlreadyExits"] = "channelAlreadyExist"; ErrorCodes["CommonError"] = "commonError"; ErrorCodes["UnAuthorized"] = "unauthorized"; })(ErrorCodes || (ErrorCodes = {})); class CreateChannelError extends BaseError_1.ApiError { constructor(response) { const errorMessages = []; if (response.errors.some((e) => (0, channel_1.createChannelErrorsFromJSON)(e) === channel_1.CreateChannelErrors.IsAlreadyExist)) { errorMessages.push({ code: ErrorCodes.ChannelAlreadyExits, message: 'Channel with given identifier already exist. Identifier should be unique', }); } if (!response.channel && response.errors.length == 0) { errorMessages.push({ code: ErrorCodes.CommonError, message: 'Unexpected error. The channel did not come in the response body', }); } if (response.errors.some((e) => (0, channel_1.createChannelErrorsFromJSON)(e) === channel_1.CreateChannelErrors.Unauthorized)) { errorMessages.push({ code: ErrorCodes.UnAuthorized, message: 'Unexpected error. The channel did not come in the response body', }); } super(errorMessages); } } exports.CreateChannelError = CreateChannelError; //# sourceMappingURL=ChannelErrors.js.map