Skip to content

Commit e4c89f9

Browse files
committed
chore: update all panics
1 parent 7825caf commit e4c89f9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ pub fn load_pnp_manifest(p: &Path) -> Result<Manifest, Error> {
153153
pub fn init_pnp_manifest(manifest: &mut Manifest, p: &Path) {
154154
manifest.manifest_path = p.to_path_buf();
155155

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();
157160

158161
for (name, ranges) in manifest.package_registry_data.iter_mut() {
159162
for (reference, info) in ranges.iter_mut() {
@@ -212,13 +215,13 @@ pub fn get_package<'a>(
212215
manifest: &'a Manifest,
213216
locator: &PackageLocator,
214217
) -> Result<&'a PackageInformation, Error> {
215-
let references = manifest
216-
.package_registry_data
217-
.get(&locator.name)
218-
.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+
});
219221

220-
let info =
221-
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+
});
222225

223226
Ok(info)
224227
}

0 commit comments

Comments
 (0)