@@ -286,65 +286,62 @@ fn transmit(
286
286
None => BTreeMap :: new ( ) ,
287
287
} ;
288
288
289
- let publish = registry. publish (
290
- & NewCrate {
291
- name : pkg. name ( ) . to_string ( ) ,
292
- vers : pkg. version ( ) . to_string ( ) ,
293
- deps,
294
- features : string_features,
295
- authors : authors. clone ( ) ,
296
- description : description. clone ( ) ,
297
- homepage : homepage. clone ( ) ,
298
- documentation : documentation. clone ( ) ,
299
- keywords : keywords. clone ( ) ,
300
- categories : categories. clone ( ) ,
301
- readme : readme_content,
302
- readme_file : readme. clone ( ) ,
303
- repository : repository. clone ( ) ,
304
- license : license. clone ( ) ,
305
- license_file : license_file. clone ( ) ,
306
- badges : badges. clone ( ) ,
307
- links : links. clone ( ) ,
308
- v : None ,
309
- } ,
310
- tarball,
311
- ) ;
312
-
313
- match publish {
314
- Ok ( warnings) => {
315
- if !warnings. invalid_categories . is_empty ( ) {
316
- let msg = format ! (
317
- "the following are not valid category slugs and were \
318
- ignored: {}. Please see https://crates.io/category_slugs \
319
- for the list of all category slugs. \
320
- ",
321
- warnings. invalid_categories. join( ", " )
322
- ) ;
323
- config. shell ( ) . warn ( & msg) ?;
324
- }
325
-
326
- if !warnings. invalid_badges . is_empty ( ) {
327
- let msg = format ! (
328
- "the following are not valid badges and were ignored: {}. \
329
- Either the badge type specified is unknown or a required \
330
- attribute is missing. Please see \
331
- https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata \
332
- for valid badge types and their required attributes.",
333
- warnings. invalid_badges. join( ", " )
334
- ) ;
335
- config. shell ( ) . warn ( & msg) ?;
336
- }
289
+ let warnings = registry
290
+ . publish (
291
+ & NewCrate {
292
+ name : pkg. name ( ) . to_string ( ) ,
293
+ vers : pkg. version ( ) . to_string ( ) ,
294
+ deps,
295
+ features : string_features,
296
+ authors : authors. clone ( ) ,
297
+ description : description. clone ( ) ,
298
+ homepage : homepage. clone ( ) ,
299
+ documentation : documentation. clone ( ) ,
300
+ keywords : keywords. clone ( ) ,
301
+ categories : categories. clone ( ) ,
302
+ readme : readme_content,
303
+ readme_file : readme. clone ( ) ,
304
+ repository : repository. clone ( ) ,
305
+ license : license. clone ( ) ,
306
+ license_file : license_file. clone ( ) ,
307
+ badges : badges. clone ( ) ,
308
+ links : links. clone ( ) ,
309
+ v : None ,
310
+ } ,
311
+ tarball,
312
+ )
313
+ . chain_err ( || format ! ( "failed to publish to registry at {}" , registry. host( ) ) ) ?;
314
+
315
+ if !warnings. invalid_categories . is_empty ( ) {
316
+ let msg = format ! (
317
+ "the following are not valid category slugs and were \
318
+ ignored: {}. Please see https://crates.io/category_slugs \
319
+ for the list of all category slugs. \
320
+ ",
321
+ warnings. invalid_categories. join( ", " )
322
+ ) ;
323
+ config. shell ( ) . warn ( & msg) ?;
324
+ }
337
325
338
- if !warnings. other . is_empty ( ) {
339
- for msg in warnings. other {
340
- config. shell ( ) . warn ( & msg) ?;
341
- }
342
- }
326
+ if !warnings. invalid_badges . is_empty ( ) {
327
+ let msg = format ! (
328
+ "the following are not valid badges and were ignored: {}. \
329
+ Either the badge type specified is unknown or a required \
330
+ attribute is missing. Please see \
331
+ https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata \
332
+ for valid badge types and their required attributes.",
333
+ warnings. invalid_badges. join( ", " )
334
+ ) ;
335
+ config. shell ( ) . warn ( & msg) ?;
336
+ }
343
337
344
- Ok ( ( ) )
338
+ if !warnings. other . is_empty ( ) {
339
+ for msg in warnings. other {
340
+ config. shell ( ) . warn ( & msg) ?;
345
341
}
346
- Err ( e) => Err ( e) ,
347
342
}
343
+
344
+ Ok ( ( ) )
348
345
}
349
346
350
347
/// Returns the index and token from the config file for the given registry.
@@ -731,9 +728,9 @@ pub fn registry_login(
731
728
input
732
729
. lock ( )
733
730
. read_line ( & mut line)
734
- . chain_err ( || "failed to read stdin" )
735
- . map_err ( anyhow :: Error :: from) ? ;
736
- // Automatically remove `cargo login` from an inputted token to allow direct pastes from `registry.host()`/me.
731
+ . chain_err ( || "failed to read stdin" ) ? ;
732
+ // Automatically remove `cargo login` from an inputted token to
733
+ // allow direct pastes from `registry.host()`/me.
737
734
line. replace ( "cargo login" , "" ) . trim ( ) . to_string ( )
738
735
}
739
736
} ;
@@ -820,9 +817,13 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> {
820
817
821
818
if let Some ( ref v) = opts. to_add {
822
819
let v = v. iter ( ) . map ( |s| & s[ ..] ) . collect :: < Vec < _ > > ( ) ;
823
- let msg = registry
824
- . add_owners ( & name, & v)
825
- . map_err ( |e| format_err ! ( "failed to invite owners to crate {}: {}" , name, e) ) ?;
820
+ let msg = registry. add_owners ( & name, & v) . chain_err ( || {
821
+ format ! (
822
+ "failed to invite owners to crate `{}` on registry at {}" ,
823
+ name,
824
+ registry. host( )
825
+ )
826
+ } ) ?;
826
827
827
828
config. shell ( ) . status ( "Owner" , msg) ?;
828
829
}
@@ -832,15 +833,23 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> {
832
833
config
833
834
. shell ( )
834
835
. status ( "Owner" , format ! ( "removing {:?} from crate {}" , v, name) ) ?;
835
- registry
836
- . remove_owners ( & name, & v)
837
- . chain_err ( || format ! ( "failed to remove owners from crate {}" , name) ) ?;
836
+ registry. remove_owners ( & name, & v) . chain_err ( || {
837
+ format ! (
838
+ "failed to remove owners from crate `{}` on registry at {}" ,
839
+ name,
840
+ registry. host( )
841
+ )
842
+ } ) ?;
838
843
}
839
844
840
845
if opts. list {
841
- let owners = registry
842
- . list_owners ( & name)
843
- . chain_err ( || format ! ( "failed to list owners of crate {}" , name) ) ?;
846
+ let owners = registry. list_owners ( & name) . chain_err ( || {
847
+ format ! (
848
+ "failed to list owners of crate `{}` on registry at {}" ,
849
+ name,
850
+ registry. host( )
851
+ )
852
+ } ) ?;
844
853
for owner in owners. iter ( ) {
845
854
drop_print ! ( config, "{}" , owner. login) ;
846
855
match ( owner. name . as_ref ( ) , owner. email . as_ref ( ) ) {
@@ -882,16 +891,19 @@ pub fn yank(
882
891
config
883
892
. shell ( )
884
893
. status ( "Unyank" , format ! ( "{}:{}" , name, version) ) ?;
885
- registry
886
- . unyank ( & name, & version)
887
- . chain_err ( || "failed to undo a yank" ) ?;
894
+ registry. unyank ( & name, & version) . chain_err ( || {
895
+ format ! (
896
+ "failed to undo a yank from the registry at {}" ,
897
+ registry. host( )
898
+ )
899
+ } ) ?;
888
900
} else {
889
901
config
890
902
. shell ( )
891
903
. status ( "Yank" , format ! ( "{}:{}" , name, version) ) ?;
892
904
registry
893
905
. yank ( & name, & version)
894
- . chain_err ( || "failed to yank" ) ?;
906
+ . chain_err ( || format ! ( "failed to yank from the registry at {}" , registry . host ( ) ) ) ?;
895
907
}
896
908
897
909
Ok ( ( ) )
@@ -937,9 +949,12 @@ pub fn search(
937
949
}
938
950
939
951
let ( mut registry, _, source_id) = registry ( config, None , index, reg, false , false ) ?;
940
- let ( crates, total_crates) = registry
941
- . search ( query, limit)
942
- . chain_err ( || "failed to retrieve search results from the registry" ) ?;
952
+ let ( crates, total_crates) = registry. search ( query, limit) . chain_err ( || {
953
+ format ! (
954
+ "failed to retrieve search results from the registry at {}" ,
955
+ registry. host( )
956
+ )
957
+ } ) ?;
943
958
944
959
let names = crates
945
960
. iter ( )
0 commit comments