• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 17033178607

18 Aug 2025 06:45AM UTC coverage: 54.49% (-0.007%) from 54.497%
17033178607

push

github

stringhandler
Merge branch 'development' of github.com:tari-project/tari into odev

971 of 2923 new or added lines in 369 files covered. (33.22%)

5804 existing lines in 173 files now uncovered.

76688 of 140739 relevant lines covered (54.49%)

193850.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/comms/core/src/protocol/error.rs
1
// Copyright 2020, The Tari Project
2
//
3
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
// following conditions are met:
5
//
6
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
// disclaimer.
8
//
9
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
// following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
// products derived from this software without specific prior written permission.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22

23
use std::io;
24

25
use thiserror::Error;
26

27
/// Error type for protocol module.
28
#[derive(Debug, Error)]
29
pub enum ProtocolError {
30
    #[error("IO error: {0}")]
31
    IoError(#[from] io::Error),
32
    #[error("Invalid flag: {0}")]
33
    InvalidFlag(String),
34
    #[error("The ProtocolId was longer than {}", u8::MAX)]
35
    ProtocolIdTooLong,
36
    #[error("Protocol negotiation failed because the peer did not accept any of the given protocols: {protocols}")]
37
    ProtocolOutboundNegotiationFailed { protocols: String },
38
    #[error("Protocol negotiation failed because the peer did not offer any protocols supported by this node")]
39
    ProtocolInboundNegotiationFailed,
40
    #[error("Optimistic protocol negotiation failed because the peer did not offer a protocol supported by this node")]
41
    ProtocolOptimisticNegotiationFailed,
42
    #[error("Protocol negotiation terminated by peer")]
43
    ProtocolNegotiationTerminatedByPeer,
44
    #[error("Protocol was not registered")]
45
    ProtocolNotRegistered,
46
    #[error("Failed to send notification because notification sender disconnected")]
47
    NotificationSenderDisconnected,
48
    #[error("Expected to ready bytes, that are not in the buffer")]
49
    ExpectedReadyBytes,
50
}
51

52
impl ProtocolError {
53
    pub fn is_ban_offence(&self) -> bool {
1✔
54
        match self {
1✔
55
            ProtocolError::IoError(_) |
56
            ProtocolError::ProtocolNegotiationTerminatedByPeer |
57
            ProtocolError::ProtocolOutboundNegotiationFailed { .. } |
58
            ProtocolError::ProtocolNotRegistered |
59
            ProtocolError::ProtocolInboundNegotiationFailed |
60
            ProtocolError::ProtocolOptimisticNegotiationFailed |
61
            ProtocolError::ExpectedReadyBytes |
62
            ProtocolError::NotificationSenderDisconnected => false,
1✔
63

UNCOV
64
            ProtocolError::ProtocolIdTooLong | ProtocolError::InvalidFlag(_) => true,
×
65
        }
66
    }
1✔
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc