Skip to content

Commit

Permalink
Update Observable+Result.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbruel authored Jan 24, 2017
1 parent 1f3bb69 commit b983ab4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion RxResult/Classes/Observable+Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public extension ObservableType {

public func mapResult<U: RxResultError>(_ errorType: U.Type) -> Observable<Result<E, U>> {
return self.map(Result<E, U>.success)
.catchError{ .just(Result.failure(U.failure(from: $0))) }
.catchError{ error in
if let error = error as? U {
return .just(Result.failure(error))
}
return .just(Result.failure(U.failure(from: error))) }
}
}

Expand Down

0 comments on commit b983ab4

Please sign in to comment.