mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Replace fatalErrors with prints and exits
This commit is contained in:
@@ -33,11 +33,12 @@ class BZip2Command: Command {
|
||||
} else if inputURL.pathExtension == "bz2" {
|
||||
outputURL = inputURL.deletingPathExtension()
|
||||
} else {
|
||||
fatalError("""
|
||||
Unable to get output path.
|
||||
No output parameter was specified.
|
||||
Extension was: \(inputURL.pathExtension)
|
||||
""")
|
||||
print("""
|
||||
ERROR: Unable to get output path. \
|
||||
No output parameter was specified. \
|
||||
Extension was: \(inputURL.pathExtension)
|
||||
""")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let fileData = try Data(contentsOf: inputURL, options: .mappedIfSafe)
|
||||
@@ -57,7 +58,8 @@ class BZip2Command: Command {
|
||||
let compressedData = BZip2.compress(data: fileData)
|
||||
try compressedData.write(to: outputURL)
|
||||
} else {
|
||||
fatalError("Neither compress nor decompress option in BZip2Command.")
|
||||
print("ERROR: Neither compress nor decompress option in BZip2Command.")
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,12 @@ class GZipCommand: Command {
|
||||
} else if inputURL.pathExtension == "gz" {
|
||||
outputURL = inputURL.deletingPathExtension()
|
||||
} else {
|
||||
fatalError("""
|
||||
Unable to get output path.
|
||||
No output parameter was specified.
|
||||
Extension was: \(inputURL.pathExtension)
|
||||
""")
|
||||
print("""
|
||||
ERROR: Unable to get output path. \
|
||||
No output parameter was specified. \
|
||||
Extension was: \(inputURL.pathExtension)
|
||||
""")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let fileData = try Data(contentsOf: inputURL, options: .mappedIfSafe)
|
||||
@@ -60,7 +61,8 @@ class GZipCommand: Command {
|
||||
writeHeaderCRC: true)
|
||||
try compressedData.write(to: outputURL)
|
||||
} else {
|
||||
fatalError("Neither compress nor decompress option in GZipCommand.")
|
||||
print("ERROR: Neither compress nor decompress option in GZipCommand.")
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user