@@ -4,13 +4,15 @@ use rustc_serialize::{Encodable, Decodable};
4
4
use toml:: { self , Encoder , Value } ;
5
5
6
6
use core:: { Resolve , resolver, Package , SourceId } ;
7
- use util:: CargoResult ;
7
+ use util:: { CargoResult , ChainError , human } ;
8
8
use util:: toml as cargo_toml;
9
9
10
10
pub fn load_pkg_lockfile ( pkg : & Package ) -> CargoResult < Option < Resolve > > {
11
11
let lockfile = pkg. get_manifest_path ( ) . dir_path ( ) . join ( "Cargo.lock" ) ;
12
12
let source_id = pkg. get_package_id ( ) . get_source_id ( ) ;
13
- load_lockfile ( & lockfile, source_id)
13
+ load_lockfile ( & lockfile, source_id) . chain_error ( || {
14
+ human ( format ! ( "failed to parse lock file at: {}" , lockfile. display( ) ) )
15
+ } )
14
16
}
15
17
16
18
pub fn load_lockfile ( path : & Path , sid : & SourceId ) -> CargoResult < Option < Resolve > > {
@@ -24,7 +26,7 @@ pub fn load_lockfile(path: &Path, sid: &SourceId) -> CargoResult<Option<Resolve>
24
26
25
27
let table = toml:: Value :: Table ( try!( cargo_toml:: parse ( s. as_slice ( ) , path) ) ) ;
26
28
let mut d = toml:: Decoder :: new ( table) ;
27
- let v: resolver:: EncodableResolve = Decodable :: decode ( & mut d) . unwrap ( ) ;
29
+ let v: resolver:: EncodableResolve = try! ( Decodable :: decode ( & mut d) ) ;
28
30
Ok ( Some ( try!( v. to_resolve ( sid) ) ) )
29
31
}
30
32
0 commit comments