Skip to content

Commit

Permalink
Add #[non_exhaustive] to error enums (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored Nov 21, 2023
1 parent a73ad8c commit bf7a485
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::{

/// An error that occurred during decoding.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum CodecError {
/// An I/O error.
#[error("I/O error")]
Expand Down
1 change: 1 addition & 0 deletions src/dp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};

/// Errors propagated by methods in this module.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum DpError {
/// Tried to use an invalid float as privacy parameter.
#[error(
Expand Down
1 change: 1 addition & 0 deletions src/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::convert::TryFrom;

/// An error returned by an FFT operation.
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum FftError {
/// The output is too small.
#[error("output slice is smaller than specified size")]
Expand Down
1 change: 1 addition & 0 deletions src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub use field255::Field255;

/// Possible errors from finite field operations.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum FieldError {
/// Input sizes do not match.
#[error("input sizes do not match")]
Expand Down
1 change: 1 addition & 0 deletions src/flp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub mod types;

/// Errors propagated by methods in this module.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum FlpError {
/// Calling [`Type::prove`] returned an error.
#[error("prove error: {0}")]
Expand Down
1 change: 1 addition & 0 deletions src/idpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use subtle::{Choice, ConditionallyNegatable, ConditionallySelectable, ConstantTi

/// IDPF-related errors.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum IdpfError {
/// Error from incompatible shares at different levels.
#[error("tried to merge shares from incompatible levels")]
Expand Down
1 change: 1 addition & 0 deletions src/prng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const BUFFER_SIZE_IN_ELEMENTS: usize = 32;

/// Errors propagated by methods in this module.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PrngError {
/// Failure when calling getrandom().
#[error("getrandom: {0}")]
Expand Down
1 change: 1 addition & 0 deletions src/topology/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::fmt::Debug;

/// Errors emitted by this module.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PingPongError {
/// Error running prepare_init
#[error("vdaf.prepare_init: {0}")]
Expand Down
1 change: 1 addition & 0 deletions src/vdaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub(crate) const VERSION: u8 = 7;

/// Errors emitted by this module.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum VdafError {
/// An error occurred.
#[error("vdaf error: {0}")]
Expand Down

0 comments on commit bf7a485

Please sign in to comment.