Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use bail! insted of anyhow #94

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cgroups/v1/hugetlb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fs, path::Path};

use anyhow::anyhow;
use anyhow::bail;
use regex::Regex;

use crate::cgroups::{
Expand Down Expand Up @@ -34,11 +34,11 @@ impl Hugetlb {
let re = Regex::new(r"(?P<pagesize>[0-9]+)[KMG]B")?;
let caps = re.captures(&hugetlb.page_size);
match caps {
None => return Err(anyhow!("page size must be in the format [0-9]+[KMG]B")),
None => bail!("page size must be in the format [0-9]+[KMG]B"),
Some(caps) => {
let page_size: u64 = caps["pagesize"].parse()?;
if !Self::is_power_of_two(page_size) {
return Err(anyhow!("page size must be in the format of 2^(integer)"));
bail!("page size must be in the format of 2^(integer)");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cgroups/v2/cpu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, Result};
use anyhow::{bail, Result};
use std::path::Path;

use crate::cgroups::common;
Expand Down Expand Up @@ -26,7 +26,7 @@ impl Controller for Cpu {
impl Cpu {
fn apply(path: &Path, cpu: &LinuxCpu) -> Result<()> {
if Self::is_realtime_requested(cpu) {
return Err(anyhow!("realtime is not supported on cgroup v2 yet"));
bail!("realtime is not supported on cgroup v2 yet");
}

if let Some(mut shares) = cpu.shares {
Expand Down