[EventLoopFuture] Ensure client #file/#line are forwarded in mapIfError. (#533)

Motivation:

This ensures that the client's context information will be propagated into
the promise which is implicitly created by thenIfError(). Without this, if
that promise leaked the client would only see information about where it was
allocated inside of NIO, which is not helpful.

Modifications:

Propagate #file/#line.

Result:

Client's will see a #file/#line in their code, rather than something like:

```
Fatal error: leaking promise created at (file: ".../.build/checkouts/swift-nio.git-bla/Sources/NIO/EventLoopFuture.swift", line: 583)
```
This commit is contained in:
Daniel Dunbar authored and Cory Benfield committed 2018-07-31 08:42:27 +01:00
1 parent f55fc64535
commit d31f4a249a
1 file changed
+3 -1
+3 -1
View File
@@ -580,7 +580,9 @@ extension EventLoopFuture {
/// a new value lifted into a new `EventLoopFuture`.
/// - returns: A future that will receive the recovered value.
public func mapIfError(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) -> T) -> EventLoopFuture<T> {
return thenIfError { return EventLoopFuture<T>(eventLoop: self.eventLoop, result: callback($0), file: file, line: line) }
return thenIfError(file: file, line: line) {
return EventLoopFuture<T>(eventLoop: self.eventLoop, result: callback($0), file: file, line: line)
}
}