Skip to content

Commit

Permalink
Update send() to forward all errors (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
buildbreaker authored Mar 9, 2023
1 parent b2f5e55 commit 69c77b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ class Stream(
if (isClosed()) {
return Result.failure(IllegalStateException("cannot send. underlying stream is closed"))
}
onSend(buffer)
return Result.success(Unit)
return try {
onSend(buffer)
Result.success(Unit)
} catch (e: Throwable) {
Result.failure(e)
}
}

fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal class PipeDuplexRequestBody(
bufferedSink.writeAll(buffer)
bufferedSink.flush()
}
} catch (e: Throwable) {
} finally {
close()
}
}
Expand Down

0 comments on commit 69c77b6

Please sign in to comment.