Skip to content

Commit

Permalink
fix: return error (instead of panic) when package contain a Program
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Nov 14, 2024
1 parent 01e78e5 commit 3da796d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions midenc-session/src/libs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloc::{borrow::Cow, boxed::Box, format, str::FromStr, string::ToString, sync::Arc};
use core::{fmt, panic};
use core::fmt;
use std::{
ffi::OsStr,
path::{Path, PathBuf},
Expand Down Expand Up @@ -111,7 +111,10 @@ impl LinkLibrary {
let package = miden_package::Package::read_from_bytes(bytes)?;
let lib = match package.mast {
miden_package::MastArtifact::Executable(_) => {
panic!("expected library for Miden package, not program")
return Err(Report::msg(format!(
"Expected Miden package to contain a Library, got Program: '{}'",
path.display()
)))
}
miden_package::MastArtifact::Library(lib) => lib.clone(),
};
Expand Down

0 comments on commit 3da796d

Please sign in to comment.