Skip to content

Commit 8ca3923

Browse files
bors[bot]irevoire
andauthored
Merge #234
234: Refactorise the errors r=brunoocasali a=irevoire - Merge the two meilisearch error types - Use Deserialize and Serialize to generate the string associated with every error instead of writing it by hand Co-authored-by: Irevoire <tamo@meilisearch.com>
2 parents 2d12b3b + f9e708d commit 8ca3923

File tree

4 files changed

+239
-241
lines changed

4 files changed

+239
-241
lines changed

src/client.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,11 @@ mod tests {
663663
let error = client.delete_key("invalid_key").await.unwrap_err();
664664
assert!(matches!(
665665
error,
666-
Error::MeiliSearchError {
666+
Error::Meilisearch(MeilisearchError {
667667
error_code: ErrorCode::ApiKeyNotFound,
668668
error_type: ErrorType::InvalidRequest,
669669
..
670-
}
670+
})
671671
));
672672

673673
// ==> executing the action without enough right
@@ -681,21 +681,21 @@ mod tests {
681681
let error = client.delete_key("invalid_key").await.unwrap_err();
682682
assert!(matches!(
683683
error,
684-
Error::MeiliSearchError {
684+
Error::Meilisearch(MeilisearchError {
685685
error_code: ErrorCode::InvalidApiKey,
686686
error_type: ErrorType::Auth,
687687
..
688-
}
688+
})
689689
));
690690
// with a good key
691691
let error = client.delete_key(&key.key).await.unwrap_err();
692692
assert!(matches!(
693693
error,
694-
Error::MeiliSearchError {
694+
Error::Meilisearch(MeilisearchError {
695695
error_code: ErrorCode::InvalidApiKey,
696696
error_type: ErrorType::Auth,
697697
..
698-
}
698+
})
699699
));
700700

701701
// cleanup
@@ -741,7 +741,7 @@ mod tests {
741741
742742
assert!(matches!(
743743
error,
744-
Error::MeiliSearchError {
744+
Error::MeilisearchError {
745745
error_code: ErrorCode::InvalidApiKeyIndexes,
746746
error_type: ErrorType::InvalidRequest,
747747
..
@@ -756,11 +756,11 @@ mod tests {
756756

757757
assert!(matches!(
758758
error,
759-
Error::MeiliSearchError {
759+
Error::Meilisearch(MeilisearchError {
760760
error_code: ErrorCode::InvalidApiKeyExpiresAt,
761761
error_type: ErrorType::InvalidRequest,
762762
..
763-
}
763+
})
764764
));
765765

766766
// ==> executing the action without enough right
@@ -776,11 +776,11 @@ mod tests {
776776

777777
assert!(matches!(
778778
error,
779-
Error::MeiliSearchError {
779+
Error::Meilisearch(MeilisearchError {
780780
error_code: ErrorCode::InvalidApiKey,
781781
error_type: ErrorType::Auth,
782782
..
783-
}
783+
})
784784
));
785785

786786
// cleanup
@@ -830,7 +830,7 @@ mod tests {
830830
831831
assert!(matches!(
832832
error,
833-
Error::MeiliSearchError {
833+
Error::MeilisearchError {
834834
error_code: ErrorCode::InvalidApiKeyIndexes,
835835
error_type: ErrorType::InvalidRequest,
836836
..
@@ -844,11 +844,11 @@ mod tests {
844844

845845
assert!(matches!(
846846
error,
847-
Error::MeiliSearchError {
847+
Error::Meilisearch(MeilisearchError {
848848
error_code: ErrorCode::InvalidApiKeyExpiresAt,
849849
error_type: ErrorType::InvalidRequest,
850850
..
851-
}
851+
})
852852
));
853853
key.expires_at = None;
854854

@@ -864,11 +864,11 @@ mod tests {
864864

865865
assert!(matches!(
866866
error,
867-
Error::MeiliSearchError {
867+
Error::Meilisearch(MeilisearchError {
868868
error_code: ErrorCode::InvalidApiKey,
869869
error_type: ErrorType::Auth,
870870
..
871-
}
871+
})
872872
));
873873

874874
// cleanup

0 commit comments

Comments
 (0)