Skip to content

Commit

Permalink
replace std::Result with anyhow::Result
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <18012015693@163.com>
  • Loading branch information
He1pa committed Nov 1, 2024
1 parent ffded1d commit 0961bb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions kclvm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kclvm/ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ kclvm-span = { path = "../span" }
kclvm-error = { path = "../error" }
thread_local = "1.1.7"
kclvm-utils = {path = "../utils"}
anyhow = "1.0"

[dev-dependencies]
kclvm-parser = { path = "../parser" }
8 changes: 4 additions & 4 deletions kclvm/ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ impl Program {
pub fn get_module(
&self,
module_path: &str,
) -> Result<Option<RwLockReadGuard<'_, Module>>, &str> {
) -> anyhow::Result<Option<RwLockReadGuard<'_, Module>>> {
match self.modules.get(module_path) {
Some(module_ref) => match module_ref.read() {
Ok(m) => Ok(Some(m)),
Err(_) => Err("Failed to acquire module lock"),
Err(_) => Err(anyhow::anyhow!("Failed to acquire module lock")),
},
None => Ok(None),
}
Expand All @@ -465,11 +465,11 @@ impl Program {
pub fn get_module_mut(
&self,
module_path: &str,
) -> Result<Option<RwLockWriteGuard<'_, Module>>, &str> {
) -> anyhow::Result<Option<RwLockWriteGuard<'_, Module>>> {
match self.modules.get(module_path) {
Some(module_ref) => match module_ref.write() {
Ok(m) => Ok(Some(m)),
Err(_) => Err("Failed to acquire module lock"),
Err(_) => Err(anyhow::anyhow!("Failed to acquire module lock")),
},
None => Ok(None),
}
Expand Down

0 comments on commit 0961bb7

Please sign in to comment.