UNPKG

livelists-node-js

Version:
64 lines 3.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetAccessTokenError = exports.AddParticipantToChannelError = void 0; const BaseError_1 = require("../../common/BaseError"); const participant_1 = require("../../proto/participant"); var ErrorCodes; (function (ErrorCodes) { ErrorCodes["UnAuthorized"] = "unauthorized"; ErrorCodes["AlreadyExist"] = "alreadyExist"; ErrorCodes["ChannelNotFound"] = "channelNotFound"; ErrorCodes["IdentifierNotValid"] = "identifierNotValid"; ErrorCodes["ParticipantNotFound"] = "participantNotFound"; })(ErrorCodes || (ErrorCodes = {})); class AddParticipantToChannelError extends BaseError_1.ApiError { constructor(response) { const errorMessages = []; if (response.errors.some((e) => (0, participant_1.addParticipantToChannelErrorsFromJSON)(e) === participant_1.AddParticipantToChannelErrors.IsAlreadyExist)) { errorMessages.push({ code: ErrorCodes.AlreadyExist, message: 'Participant with given identifier already exist in this channel. Identifier should be unique', }); } if (response.errors.some((e) => (0, participant_1.addParticipantToChannelErrorsFromJSON)(e) === participant_1.AddParticipantToChannelErrors.IdentifierNotValid)) { errorMessages.push({ code: ErrorCodes.IdentifierNotValid, message: 'Participant identifier should be greater then 0 length', }); } if (response.errors.some((e) => (0, participant_1.addParticipantToChannelErrorsFromJSON)(e) === participant_1.AddParticipantToChannelErrors.Unauthorized)) { errorMessages.push({ code: ErrorCodes.UnAuthorized, message: 'Token sent from Server SDK incorrect', }); } if (response.errors.some((e) => (0, participant_1.addParticipantToChannelErrorsFromJSON)(e) === participant_1.AddParticipantToChannelErrors.ChannelNotFound)) { errorMessages.push({ code: ErrorCodes.ChannelNotFound, message: 'Can not join to channel. Channel with given identifier not exist', }); } super(errorMessages); } } exports.AddParticipantToChannelError = AddParticipantToChannelError; class GetAccessTokenError extends BaseError_1.ApiError { constructor(response) { const errorMessages = []; if (response.errors.some((e) => (0, participant_1.getParticipantAccessTokenErrorsFromJSON)(e) === participant_1.GetParticipantAccessTokenErrors.NotFound)) { errorMessages.push({ code: ErrorCodes.ParticipantNotFound, message: 'Participant with given identifier not found', }); } if (response.errors.some((e) => (0, participant_1.addParticipantToChannelErrorsFromJSON)(e) === participant_1.AddParticipantToChannelErrors.Unauthorized)) { errorMessages.push({ code: ErrorCodes.UnAuthorized, message: 'Token sent from Server SDK incorrect', }); } super(errorMessages); } } exports.GetAccessTokenError = GetAccessTokenError; //# sourceMappingURL=ParticipantErrors.js.map