We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 623b788 commit 32d4c0fCopy full SHA for 32d4c0f
crates/crates-io/lib.rs
@@ -436,7 +436,8 @@ impl Registry {
436
.map(|s| s.errors.into_iter().map(|s| s.detail).collect::<Vec<_>>());
437
438
match (self.handle.response_code()?, errors) {
439
- (0, None) | (200, None) => Ok(body),
+ (0, None) => Ok(body),
440
+ (code, None) if is_success(code) => Ok(body),
441
(code, Some(errors)) => Err(Error::Api {
442
code,
443
headers,
@@ -451,8 +452,12 @@ impl Registry {
451
452
}
453
454
455
+fn is_success(code: u32) -> bool {
456
+ code >= 200 && code < 300
457
+}
458
+
459
fn status(code: u32) -> String {
- if code == 200 {
460
+ if is_success(code) {
461
String::new()
462
} else {
463
let reason = reason(code);
0 commit comments