Skip to content

Commit 15eeeca

Browse files
committed
Improve error handling.
1 parent 1b5a255 commit 15eeeca

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/secret.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Error, MIN_SECRET_LEN, MAX_SECRET_LEN};
1+
use crate::{Error, Result, MIN_SECRET_LEN, MAX_SECRET_LEN};
22

33
/// A secret to be split into shares.
44
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -15,7 +15,7 @@ impl Secret {
1515
///
1616
/// Returns an error if the length of the secret is less than `MIN_SECRET_LEN`, greater than `MAX_SECRET_LEN`,
1717
/// or not even.
18-
pub fn new<T>(data: T) -> Result<Self, Error>
18+
pub fn new<T>(data: T) -> Result<Self>
1919
where
2020
T: AsRef<[u8]>,
2121
{

src/spec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bc_shamir::MAX_SHARE_COUNT;
22

3-
use crate::Error;
3+
use crate::{Error, Result};
44

55
/// A specification for an SSKR split.
66
#[derive(Debug, Clone, PartialEq)]
@@ -24,7 +24,7 @@ impl Spec {
2424
/// Returns an error if the group threshold is zero, if the group threshold
2525
/// is greater than the number of groups, or if the number of groups is
2626
/// greater than the maximum share count.
27-
pub fn new(group_threshold: usize, groups: Vec<GroupSpec>) -> Result<Self, Error> {
27+
pub fn new(group_threshold: usize, groups: Vec<GroupSpec>) -> Result<Self> {
2828
if group_threshold == 0 {
2929
return Err(Error::GroupThresholdInvalid);
3030
}
@@ -83,7 +83,7 @@ impl GroupSpec {
8383
/// Returns an error if the member count is zero, if the member count is
8484
/// greater than the maximum share count, or if the member threshold is
8585
/// greater than the member count.
86-
pub fn new(member_threshold: usize, member_count: usize) -> Result<Self, Error> {
86+
pub fn new(member_threshold: usize, member_count: usize) -> Result<Self> {
8787
if member_count == 0 {
8888
return Err(Error::MemberCountInvalid);
8989
}
@@ -107,7 +107,7 @@ impl GroupSpec {
107107
}
108108

109109
/// Parses a group specification from a string.
110-
pub fn parse(s: &str) -> Result<Self, Error> {
110+
pub fn parse(s: &str) -> Result<Self> {
111111
let parts: Vec<&str> = s.split('-').collect();
112112
if parts.len() != 3 {
113113
return Err(Error::GroupSpecInvalid);

0 commit comments

Comments
 (0)