From a6dccd1ab967545840460e259ef3403f8ad5aaca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 19 Jun 2015 12:01:05 +0200 Subject: [PATCH] WriteStream: use libgit2's error when we fail to write to the next stream --- LibGit2Sharp/Core/WriteStream.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LibGit2Sharp/Core/WriteStream.cs b/LibGit2Sharp/Core/WriteStream.cs index 37db8af8c..845fecd1d 100644 --- a/LibGit2Sharp/Core/WriteStream.cs +++ b/LibGit2Sharp/Core/WriteStream.cs @@ -49,16 +49,16 @@ public override long Seek(long offset, SeekOrigin origin) public override void Write(byte[] buffer, int offset, int count) { + int res; unsafe { fixed (byte* bufferPtr = &buffer[offset]) { - if (nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count) < 0) - { - throw new LibGit2SharpException("failed to write to next buffer"); - } + res = nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count); } } + + Ensure.Int32Result(res); } } }