Skip to main content

derec_library/primitives/sharing/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 DeRec Alliance. All rights reserved.
3
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum SharingError {
7    #[error("no channels provided")]
8    EmptyChannels,
9
10    #[error("duplicate channel id: {0}")]
11    DuplicateChannelId(u64),
12
13    #[error(
14        "invalid threshold (threshold={threshold}, channels={channels}); must satisfy 2 <= threshold <= channels"
15    )]
16    InvalidThreshold { threshold: usize, channels: usize },
17
18    #[error("secret_data is empty")]
19    EmptySecretData,
20
21    #[error("VSS failed to generate shares")]
22    VssShareFailed {
23        #[source]
24        source: derec_cryptography::vss::DerecVSSError,
25    },
26
27    #[error("share response indicates a non-OK status (status={status}): {memo}")]
28    NonOkStatus { status: i32, memo: String },
29
30    #[error("share version mismatch in share response (expected={expected}, got={got})")]
31    VersionMismatch { expected: u32, got: u32 },
32}