ErrorWrapping

public protocol ErrorWrapping<SomeError> : Error

An error that can be created with an underlying error of a specific type.

  • The type of error that this ErrorWrapping can wrap.

    Declaration

    Swift

    associatedtype SomeError : Error
  • Creates an ErrorWrapping error with the given underlying error. Usually this can be a case in an error enum.

    Declaration

    Swift

    static func underlyingError(_ error: SomeError) -> Self
  • wrapErrors(block:) Extension method

    Wraps the eventual errors thrown by the given block.

    Throws

    An ErrorWrapping that wraps the underlying error.

    Declaration

    Swift

    static func wrapErrors<T>(block: () throws(SomeError) -> T) throws(Self) -> T

    Parameters

    block

    The throwing block that can throw SomeError, which will be wrapped into an ErrorWrapping.