Files
divkit/client/ios/LayoutKit/LayoutKit/Blocks/BlockError.swift
T
2022-09-07 18:59:18 +03:00

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] { [:] }
}