Replace fatalErrors with prints and exits

This commit is contained in:
Timofey Solomko
2017-10-22 17:08:51 +03:00
parent 6811bfb554
commit f850bd311a
2 changed files with 16 additions and 12 deletions
+8 -6
View File
@@ -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)
}
}
+8 -6
View File
@@ -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)
}
}