Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Nov 28, 2024
1 parent 81f4dd6 commit 1c7dfed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions v2/app/BlockCompressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (this *BlockCompressor) Compress() (int, uint64) {
}

if len(files) == 0 {
fmt.Printf("Cannot open input file '%s'\n", this.inputName)
fmt.Println("Cannot find any file to compress")
return kanzi.ERR_OPEN_FILE, 0
}

Expand Down Expand Up @@ -450,7 +450,7 @@ func (this *BlockCompressor) Compress() (int, uint64) {
fi, err := os.Stat(formattedInName)

if err != nil {
fmt.Printf("Cannot access %s\n", formattedInName)
fmt.Println("Cannot find any file to compress")
return kanzi.ERR_OPEN_FILE, 0
}

Expand Down
9 changes: 5 additions & 4 deletions v2/app/BlockDecompressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (this *BlockDecompressor) Decompress() (int, uint64) {
}

if len(files) == 0 {
fmt.Printf("Cannot open input file '%s'\n", this.inputName)
fmt.Println("Cannot find any file to decompress")
return kanzi.ERR_OPEN_FILE, 0
}

Expand Down Expand Up @@ -751,10 +751,11 @@ func (this *fileDecompressTask) call() (int, uint64, error) {
// Delete input file
if inputName == "STDIN" {
log.Println("Warning: ignoring remove option with STDIN", verbosity > 0)
} else if os.Remove(inputName) != nil {
log.Println("Warning: input file could not be deleted", verbosity > 0)
} else if err := os.Remove(inputName); err != nil {
msg := fmt.Sprintf("Warning: input file could not be deleted (%v)\n", err)
log.Println(msg, verbosity > 0)
}
}

return 0, uint64(decoded), nil
return res, uint64(decoded), err
}

0 comments on commit 1c7dfed

Please sign in to comment.