Skip to content

Commit 7ff5e13

Browse files
tomas-sexeniananaiberta
authored andcommitted
Expand error codes
(cherry picked from commit defaeea)
1 parent 4c54f8d commit 7ff5e13

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

gxcompress/src/main/java/com/genexus/compression/GXCompressor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public class GXCompressor implements IGXCompressor {
2727
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(GXCompressor.class);
2828

2929
public static int compressFiles(Vector<String> files, String path, String format) {
30+
if (files.isEmpty()){
31+
log.error("No files have been added for compression.");
32+
return -4;
33+
}
3034
File[] toCompress = new File[files.size()];
3135
int index = 0;
3236
for (String filePath : files) {
@@ -76,6 +80,14 @@ public static Compression newCompression(String path, String format) {
7680

7781
public static int decompress(String file, String path) {
7882
File toCompress = new File(file);
83+
if (!toCompress.exists()) {
84+
log.error("The specified archive does not exist: {}", toCompress.getAbsolutePath());
85+
return -2;
86+
}
87+
if (toCompress.length() == 0L){
88+
log.error("The archive located at {} is empty", path);
89+
return -4;
90+
}
7991
String extension = getExtension(toCompress.getName());
8092
try {
8193
switch (extension.toLowerCase()) {

0 commit comments

Comments
 (0)