@@ -153,7 +153,10 @@ pub fn load_pnp_manifest(p: &Path) -> Result<Manifest, Error> {
153
153
pub fn init_pnp_manifest ( manifest : & mut Manifest , p : & Path ) {
154
154
manifest. manifest_path = p. to_path_buf ( ) ;
155
155
156
- manifest. manifest_dir = p. parent ( ) . expect ( "Should have a parent directory" ) . to_owned ( ) ;
156
+ manifest. manifest_dir = p
157
+ . parent ( )
158
+ . unwrap_or_else ( || panic ! ( "Should have a parent directory for path {}" , p. display( ) ) )
159
+ . to_owned ( ) ;
157
160
158
161
for ( name, ranges) in manifest. package_registry_data . iter_mut ( ) {
159
162
for ( reference, info) in ranges. iter_mut ( ) {
@@ -195,8 +198,9 @@ pub fn is_dependency_tree_root<'a>(manifest: &'a Manifest, locator: &'a PackageL
195
198
}
196
199
197
200
pub fn find_locator < ' a > ( manifest : & ' a Manifest , path : & Path ) -> Option < & ' a PackageLocator > {
198
- let rel_path = pathdiff:: diff_paths ( path, & manifest. manifest_dir )
199
- . expect ( "Assertion failed: Provided path should be absolute" ) ;
201
+ let rel_path = pathdiff:: diff_paths ( path, & manifest. manifest_dir ) . unwrap_or_else ( || {
202
+ panic ! ( "Assertion failed: Provided path should be absolute but received {}" , path. display( ) )
203
+ } ) ;
200
204
201
205
if let Some ( regex) = & manifest. ignore_pattern_data {
202
206
if regex. 0 . is_match ( & util:: normalize_path ( rel_path. to_string_lossy ( ) ) ) . unwrap ( ) {
@@ -211,13 +215,13 @@ pub fn get_package<'a>(
211
215
manifest : & ' a Manifest ,
212
216
locator : & PackageLocator ,
213
217
) -> Result < & ' a PackageInformation , Error > {
214
- let references = manifest
215
- . package_registry_data
216
- . get ( & locator. name )
217
- . expect ( "Should have an entry in the package registry" ) ;
218
+ let references = manifest. package_registry_data . get ( & locator. name ) . unwrap_or_else ( || {
219
+ panic ! ( "Should have an entry in the package registry for {}" , locator. name)
220
+ } ) ;
218
221
219
- let info =
220
- references. get ( & locator. reference ) . expect ( "Should have an entry in the package registry" ) ;
222
+ let info = references. get ( & locator. reference ) . unwrap_or_else ( || {
223
+ panic ! ( "Should have an entry in the package registry for {}" , locator. reference)
224
+ } ) ;
221
225
222
226
Ok ( info)
223
227
}
0 commit comments