Skip to content

Commit cf30a7b

Browse files
committed
IOExceptionHelper.ThrowIOError: Mark as public
1 parent 79d530e commit cf30a7b

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

DiskAccessLibrary/Win32/Helpers/IOExceptionHelper.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2018 Tal Aloni <[email protected]>. All rights reserved.
1+
/* Copyright (C) 2018-2024 Tal Aloni <[email protected]>. All rights reserved.
22
*
33
* You can redistribute this program and/or modify it under the terms of
44
* the GNU Lesser Public License as published by the Free Software Foundation,
@@ -37,37 +37,37 @@ public static int GetHResultFromWin32Error(Win32Error error)
3737
}
3838
}
3939

40-
/// <param name="errorCode">The Win32 error code associated with this exception</param>
41-
internal static void ThrowIOError(int errorCode, string defaultMessage)
40+
/// <param name="win32ErrorCode">The Win32 error code associated with the exception to throw</param>
41+
public static void ThrowIOError(int win32ErrorCode, string defaultMessage)
4242
{
43-
if (errorCode == (int)Win32Error.ERROR_ACCESS_DENIED)
43+
if (win32ErrorCode == (int)Win32Error.ERROR_ACCESS_DENIED)
4444
{
4545
// UnauthorizedAccessException will be thrown if stream was opened only for writing or if a user is not an administrator
4646
throw new UnauthorizedAccessException(defaultMessage);
4747
}
48-
else if (errorCode == (int)Win32Error.ERROR_SHARING_VIOLATION)
48+
else if (win32ErrorCode == (int)Win32Error.ERROR_SHARING_VIOLATION)
4949
{
5050
throw new SharingViolationException(defaultMessage);
5151
}
52-
else if (errorCode == (int)Win32Error.ERROR_SECTOR_NOT_FOUND)
52+
else if (win32ErrorCode == (int)Win32Error.ERROR_SECTOR_NOT_FOUND)
5353
{
5454
string message = defaultMessage + " The sector does not exist.";
55-
int hresult = GetHResultFromWin32Error((Win32Error)errorCode);
55+
int hresult = GetHResultFromWin32Error((Win32Error)win32ErrorCode);
5656
throw new IOException(message, hresult);
5757
}
58-
else if (errorCode == (int)Win32Error.ERROR_CRC)
58+
else if (win32ErrorCode == (int)Win32Error.ERROR_CRC)
5959
{
6060
string message = defaultMessage + " Data Error (Cyclic Redundancy Check).";
6161
throw new CyclicRedundancyCheckException(message);
6262
}
63-
else if (errorCode == (int)Win32Error.ERROR_NO_SYSTEM_RESOURCES)
63+
else if (win32ErrorCode == (int)Win32Error.ERROR_NO_SYSTEM_RESOURCES)
6464
{
6565
throw new OutOfMemoryException();
6666
}
6767
else
6868
{
69-
string message = defaultMessage + String.Format(" Win32 Error: {0}", errorCode);
70-
int hresult = GetHResultFromWin32Error((Win32Error)errorCode);
69+
string message = defaultMessage + String.Format(" Win32 Error: {0}", win32ErrorCode);
70+
int hresult = GetHResultFromWin32Error((Win32Error)win32ErrorCode);
7171
throw new IOException(message, hresult);
7272
}
7373
}

0 commit comments

Comments
 (0)