Skip to content

Commit

Permalink
session: Use anyhow macro for error return
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Fanelli <[email protected]>
  • Loading branch information
tylerfanelli committed Oct 15, 2024
1 parent 89b9675 commit 0fcf2c9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{

use ::sev::{certs::sev::sev::Certificate, launch::sev, session};

use anyhow::anyhow;
use codicon::{Decoder, Encoder};

pub fn cmd(name: Option<String>, pdh: PathBuf, policy: u32) -> super::Result<()> {
Expand All @@ -25,9 +26,14 @@ pub fn cmd(name: Option<String>, pdh: PathBuf, policy: u32) -> super::Result<()>
let pdh_file = fs::File::open(pdh).context("couldn't open PDH file pointed to by path")?;
let pdh = Certificate::decode(pdh_file, ()).unwrap();

let start = session
.start_pdh(pdh)
.context("could not start session based off of provided certificate chain")?;
let start = match session.start_pdh(pdh) {
Ok(s) => s,
Err(_) => {
return Err(anyhow!(
"could not start session based off of provided certificate chain"
))
}
};

let launch_blob = unsafe {
from_raw_parts(
Expand Down

0 comments on commit 0fcf2c9

Please sign in to comment.