mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
26 lines
541 B
Swift
26 lines
541 B
Swift
import Foundation
|
|
|
|
import CommonCore
|
|
|
|
public protocol BlockError: Error {
|
|
var errorMessage: NonEmptyString { get }
|
|
var userInfo: [String: String] { get }
|
|
}
|
|
|
|
// Workaround for swift compiler bug, when protocol is not conforming parent protocol
|
|
@inlinable
|
|
public func modifyError<T: Error, R>(
|
|
_ modificator: (BlockError) -> T,
|
|
_ block: () throws -> R
|
|
) throws -> R {
|
|
do {
|
|
return try block()
|
|
} catch let e as BlockError {
|
|
throw modificator(e)
|
|
}
|
|
}
|
|
|
|
extension BlockError {
|
|
public var userInfo: [String: String] { [:] }
|
|
}
|