Skip to content

Commit

Permalink
[AnyError] Separate protocol conformances from the type
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo committed Nov 28, 2016
1 parent 1a12328 commit aac425d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Result/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public enum NoError: Swift.Error { }

/// A type-erased error which wraps an arbitrary error instance. This should be
/// useful for generic contexts.
public struct AnyError: Swift.Error, ErrorProtocolConvertible, CustomStringConvertible {
public struct AnyError: Swift.Error {
/// The underlying error.
public let error: Swift.Error

Expand All @@ -196,11 +196,15 @@ public struct AnyError: Swift.Error, ErrorProtocolConvertible, CustomStringConve
self.error = error
}
}
}

extension AnyError: ErrorProtocolConvertible {
public static func error(from error: Error) -> AnyError {
return AnyError(error)
}
}

extension AnyError: CustomStringConvertible {
public var description: String {
return String(describing: error)
}
Expand Down

0 comments on commit aac425d

Please sign in to comment.