Skip to content

Commit aa90fb4

Browse files
committed
Throw error instead of fatal error
1 parent 037646a commit aa90fb4

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

Sources/CryptoSwift/BlockDecryptor.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
//
1414

1515
public class BlockDecryptor: Cryptor, Updatable {
16+
17+
public enum Error: Swift.Error {
18+
case unsupported
19+
}
20+
1621
@usableFromInline
1722
let blockSize: Int
1823

@@ -87,7 +92,7 @@ public class BlockDecryptor: Cryptor, Updatable {
8792

8893
public func seek(to position: Int) throws {
8994
guard var worker = self.worker as? SeekableModeWorker else {
90-
fatalError("Not supported")
95+
throw Error.unsupported
9196
}
9297

9398
try worker.seek(to: position)

Sources/CryptoSwift/BlockEncryptor.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
@usableFromInline
1616
final class BlockEncryptor: Cryptor, Updatable {
17+
18+
public enum Error: Swift.Error {
19+
case unsupported
20+
}
21+
1722
private let blockSize: Int
1823
private var worker: CipherModeWorker
1924
private let padding: Padding
@@ -57,6 +62,6 @@ final class BlockEncryptor: Cryptor, Updatable {
5762

5863
@usableFromInline
5964
func seek(to: Int) throws {
60-
fatalError("Not supported")
65+
throw Error.unsupported
6166
}
6267
}

Sources/CryptoSwift/StreamDecryptor.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
@usableFromInline
1616
final class StreamDecryptor: Cryptor, Updatable {
1717

18+
@usableFromInline
19+
enum Error: Swift.Error {
20+
case unsupported
21+
}
22+
1823
@usableFromInline
1924
internal let blockSize: Int
2025

@@ -83,7 +88,7 @@ final class StreamDecryptor: Cryptor, Updatable {
8388
@inlinable
8489
public func seek(to position: Int) throws {
8590
guard var worker = self.worker as? SeekableModeWorker else {
86-
fatalError("Not supported")
91+
throw Error.unsupported
8792
}
8893

8994
try worker.seek(to: position)

Sources/CryptoSwift/StreamEncryptor.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
@usableFromInline
1616
final class StreamEncryptor: Cryptor, Updatable {
1717

18+
@usableFromInline
19+
enum Error: Swift.Error {
20+
case unsupported
21+
}
22+
1823
@usableFromInline
1924
internal let blockSize: Int
2025

@@ -63,6 +68,6 @@ final class StreamEncryptor: Cryptor, Updatable {
6368

6469
@usableFromInline
6570
func seek(to: Int) throws {
66-
fatalError("Not supported")
71+
throw Error.unsupported
6772
}
6873
}

0 commit comments

Comments
 (0)