-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve error msg for collections not found or empty (#698)
* feat: improve error msg for collections not found or empty Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * test: unknown and empty storage and datastore collection Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> --------- Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
- Loading branch information
1 parent
632cfd2
commit 17d3f41
Showing
8 changed files
with
170 additions
and
53 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
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 |
---|---|---|
@@ -1,3 +1,30 @@ | ||
/// Rules | ||
pub const COLLECTION_NOT_FOUND: &str = "Collection not found: "; | ||
use crate::types::core::CollectionKey; | ||
|
||
pub const COLLECTION_NOT_EMPTY: &str = "Collection not empty: "; | ||
|
||
pub fn msg_db_collection_not_empty(collection: &CollectionKey) -> String { | ||
msg_collection_not_empty(collection, &"Datastore".to_string()) | ||
} | ||
|
||
pub fn msg_storage_collection_not_empty(collection: &CollectionKey) -> String { | ||
msg_collection_not_empty(collection, &"Storage".to_string()) | ||
} | ||
|
||
fn msg_collection_not_empty(collection: &CollectionKey, name: &String) -> String { | ||
format!( | ||
r#"The "{}" collection in {} is not empty."#, | ||
collection, name | ||
) | ||
} | ||
|
||
pub fn msg_db_collection_not_found(collection: &CollectionKey) -> String { | ||
msg_collection_not_found(collection, &"Datastore".to_string()) | ||
} | ||
|
||
pub fn msg_storage_collection_not_found(collection: &CollectionKey) -> String { | ||
msg_collection_not_found(collection, &"Storage".to_string()) | ||
} | ||
|
||
fn msg_collection_not_found(collection: &CollectionKey, name: &String) -> String { | ||
format!(r#"Collection "{}" not found in {}."#, collection, name) | ||
} |
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
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
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
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
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
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