Skip to content

Commit

Permalink
feat: 修改 core 错误信息
Browse files Browse the repository at this point in the history
  • Loading branch information
1739616529 committed Jan 11, 2024
1 parent 638ac76 commit 67dcff9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
19 changes: 4 additions & 15 deletions crates/nsv/src/command/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,14 @@ pub struct Add {
#[async_trait]
impl Command for Add {
async fn apply(&self, _config: &NsvConfig, core: &mut NsvCore) -> Result<(), NsvCoreError> {
match core.add_version(self.version.clone()).await {

Ok(()) => {
let node_item = core.context.node_item.clone().unwrap();
print_log_1!("nsv: {} add successlfy!", node_item.version)
}
Err(err) => {
if err == NsvCoreError::NodeItemExisted {
let node_item = core.context.node_item.clone().unwrap();
print_log_1!("{} already exist!", node_item.version);
return Ok(());
}
core.add_version(self.version.clone()).await?;

return Err(err);


}
if let Some(node_item) = &core.context.node_item {
print_log_1!("nsv: {} add successlfy!", node_item.version);
}
Ok(())

}
}

Expand Down
5 changes: 5 additions & 0 deletions crates/root/src/core/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ pub enum VersionTarget {

#[derive(PartialEq, Debug)]
pub enum NsvCoreError {
/**
* 自定义报错信息
*/
String(String),

/**
* 空值
*/
Expand Down

0 comments on commit 67dcff9

Please sign in to comment.