internal Exception WinIOError(int errorCode)
{
switch (errorCode)
{
case Interop.Errors.ERROR_BROKEN_PIPE:
case Interop.Errors.ERROR_PIPE_NOT_CONNECTED:
case Interop.Errors.ERROR_NO_DATA:
// Other side has broken the connection
_state = PipeState.Broken;
return new IOException(SR.IO_PipeBroken, Win32Marshal.MakeHRFromErrorCode(errorCode));
case Interop.Errors.ERROR_HANDLE_EOF:
return Error.GetEndOfFile();
case Interop.Errors.ERROR_INVALID_HANDLE:
// For invalid handles, detect the error and mark our handle
// as invalid to give slightly better error messages. Also
// help ensure we avoid handle recycling bugs.
_handle.SetHandleAsInvalid();
_state = PipeState.Broken;
break;
}
return Win32Marshal.GetExceptionForWin32Error(errorCode);
}
}