All files / lib/gossip-old GossipError.ts

40% Statements 6/15
50% Branches 2/4
50% Functions 1/2
40% Lines 6/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29    1x 1x 1x 1x 1x     1x                                      
import { IWireMessage } from "../messages/IWireMessage";
 
export enum GossipErrorCode {
    Unknown = 0,
    PeerNotReady,
    ReplyChannelRangeNoInformation,
    ReplyChannelsNoInfo,
}
 
export class GossipError extends Error {
    public code: GossipErrorCode;
    public wireMessage: IWireMessage;
 
    constructor(code: GossipErrorCode, wireMessage?: IWireMessage) {
        let message = "Unknown gossip error";
        switch (code) {
            case GossipErrorCode.ReplyChannelRangeNoInformation:
                message = "reply_channel_range had no information";
                break;
            case GossipErrorCode.ReplyChannelsNoInfo:
                message = "reply_short_channel_ids_end had no information";
                break;
        }
        super(message);
        this.code = code;
        this.wireMessage = wireMessage;
    }
}