优化error输出

This commit is contained in:
algotao
2026-01-11 17:24:11 +08:00
parent 5e102ea8e7
commit 369023b81d
45 changed files with 304 additions and 552 deletions

View File

@@ -55,8 +55,7 @@ func RunTaskMake(args ...string) error {
ds := paramDataSpaceId(fs)
if err := fs.Parse(args); err != nil {
fmt.Fprintln(os.Stderr, "command line parse error", "err", err)
return err
return fmt.Errorf("Command line parse error: %w", err)
}
if fs.NArg() > 0 || len(*sourcePath) == 0 || len(*hashFile) == 0 || len(*ds) == 0 {
@@ -64,9 +63,8 @@ func RunTaskMake(args ...string) error {
return nil
}
if strings.ToLower(*ds) == "openid" && len(*appid) == 0 {
fmt.Fprintln(os.Stderr, "appid must be set when data space is openid")
return nil
if strings.ToLower(*ds) == "wuid" && len(*appid) == 0 {
return fmt.Errorf("appid must be set when data space is wuid")
}
blockSizeNum, err := ParseByteSize(*blockSize)
@@ -77,8 +75,7 @@ func RunTaskMake(args ...string) error {
}
if blockSizeNum < blockSizeMin || blockSizeNum > blockSizeMax {
fmt.Fprintln(os.Stderr, "block size error", "min", blockSizeMin, "max", blockSizeMax)
return nil
return fmt.Errorf("block size error. min: %v, max: %v, current: %v", blockSizeMin, blockSizeMax, blockSizeNum)
}
makeTaskParams := &makeTaskParams{