"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamrClientError = void 0;
class StreamrClientError extends Error {
    code;
    messageId;
    constructor(message, code, streamMessage) {
        super(`${message} ${formErrorMessageSuffix(code, streamMessage)}`);
        this.code = code;
        this.name = this.constructor.name;
        this.messageId = streamMessage?.messageId;
    }
}
exports.StreamrClientError = StreamrClientError;
const formErrorMessageSuffix = (code, streamMessage) => {
    const parts = [];
    parts.push(`code=${code}`);
    if (streamMessage !== undefined) {
        parts.push(`messageId=${formMessageIdDescription(streamMessage.messageId)}`);
    }
    return `(${parts.join(', ')})`;
};
const formMessageIdDescription = (messageId) => {
    return JSON.stringify(messageId);
};
//# sourceMappingURL=StreamrClientError.js.map