-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(dif): Create type for DIF validation errors
Having a type for DIF validation errors will give us more flexible error handling abilities.
- Loading branch information
1 parent
ace07ee
commit ed061bf
Showing
2 changed files
with
38 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! Error types for the dif_upload module. | ||
use thiserror::Error; | ||
|
||
/// Represents an error that makes a DIF invalid. | ||
#[derive(Debug, Error)] | ||
pub enum ValidationError { | ||
#[error("Invalid format")] | ||
InvalidFormat, | ||
#[error("Invalid features")] | ||
InvalidFeatures, | ||
#[error("Invalid debug ID")] | ||
InvalidDebugId, | ||
#[error("Debug file is too large")] | ||
TooLarge, | ||
} | ||
|
||
/// Handles a DIF validation error by logging it to console | ||
/// at the appropriate log level. | ||
pub fn handle(dif_name: &str, error: &ValidationError) { | ||
log::debug!("Skipping {}: {}", dif_name, error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters