优化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

@@ -22,8 +22,7 @@ func RunTaskUpload(args ...string) error {
sha256 := paramSha256(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(*sha256) == 0 {
@@ -33,8 +32,7 @@ func RunTaskUpload(args ...string) error {
cfg, err := LoadConfigFile(*cfgFile)
if err != nil {
fmt.Fprintln(os.Stderr, "LoadConfigFile error", "err", err)
return err
return fmt.Errorf("LoadConfigFile error: %w", err)
}
uploadTaskParams := uploadTaskParams{
@@ -94,9 +92,7 @@ func doTaskUpload(uploadTaskParams uploadTaskParams) error {
}
if blockRes.GetCode() != saasapi.ErrorCode_SUCC {
err = fmt.Errorf("upload block error, code %d, msg %s", blockRes.GetCode(), blockRes.GetStatus())
fmt.Fprintln(os.Stderr, err)
return err
return fmt.Errorf("upload block error, code %d, msg %s", blockRes.GetCode(), blockRes.GetStatus())
} else {
fmt.Printf("upload block success. file: %v, sha256 %v. block %v/%v, file %v/%v\n",
finfo.GetFileName(), binfo.GetBlockSha256(),