Commit 38f6076 1 parent bd0e4ca commit 38f6076 Copy full SHA for 38f6076
File tree 1 file changed +17
-4
lines changed
1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,32 @@ package pzip
2
2
3
3
import (
4
4
"os"
5
+
6
+ "github.com/pkg/errors"
5
7
)
6
8
7
9
type CLI struct {
8
10
ArchivePath string
9
11
DirPath string
10
12
}
11
13
12
- func (c * CLI ) Archive () {
13
- archive , _ := os .Create (c .ArchivePath )
14
+ func (c * CLI ) Archive () error {
15
+ archive , err := os .Create (c .ArchivePath )
16
+ if err != nil {
17
+ return errors .Errorf ("ERROR: could not create archive at %s" , c .ArchivePath )
18
+ }
14
19
defer archive .Close ()
15
20
16
- archiver , _ := NewArchiver (archive )
21
+ archiver , err := NewArchiver (archive )
22
+ if err != nil {
23
+ return errors .Wrap (err , "ERROR: could not create archiver" )
24
+ }
17
25
defer archiver .Close ()
18
26
19
- archiver .ArchiveDir (c .DirPath )
27
+ err = archiver .ArchiveDir (c .DirPath )
28
+ if err != nil {
29
+ return errors .Wrapf (err , "ERROR: could not archive directory %s" , c .DirPath )
30
+ }
31
+
32
+ return nil
20
33
}
You can’t perform that action at this time.
0 commit comments