Skip to content

Commit a978dd5

Browse files
committed
if error caught from catch is already Self, just throw it directly rather than wrapping in a caught enum.
1 parent 2f46f64 commit a978dd5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/ErrorKit/Catching.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ extension Catching {
135135
) throws(Self) -> ReturnType {
136136
do {
137137
return try operation()
138+
} catch let error as Self {
139+
throw error
138140
} catch {
139141
throw Self.caught(error)
140142
}
@@ -180,6 +182,8 @@ extension Catching {
180182
) async throws(Self) -> ReturnType {
181183
do {
182184
return try await operation()
185+
} catch let error as Self {
186+
throw error
183187
} catch {
184188
throw Self.caught(error)
185189
}

0 commit comments

Comments
 (0)