Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetExceptionForWin32Error() [6/6]

static Exception System.IO.Win32Marshal.GetExceptionForWin32Error ( int errorCode,
string path = "" )
inlinestaticpackage

Definition at line 12 of file Win32Marshal.cs.

13 {
14 switch (errorCode)
15 {
16 case 2:
17 return new FileNotFoundException(string.IsNullOrEmpty(path) ? SR.IO_FileNotFound : SR.Format(SR.IO_FileNotFound_FileName, path), path);
18 case 3:
19 return new DirectoryNotFoundException(string.IsNullOrEmpty(path) ? SR.IO_PathNotFound_NoPathName : SR.Format(SR.IO_PathNotFound_Path, path));
20 case 5:
21 return new UnauthorizedAccessException(string.IsNullOrEmpty(path) ? SR.UnauthorizedAccess_IODenied_NoPathName : SR.Format(SR.UnauthorizedAccess_IODenied_Path, path));
22 case 183:
23 if (!string.IsNullOrEmpty(path))
24 {
25 return new IOException(SR.Format(SR.IO_AlreadyExists_Name, path), MakeHRFromErrorCode(errorCode));
26 }
27 break;
28 case 206:
29 return new PathTooLongException(string.IsNullOrEmpty(path) ? SR.IO_PathTooLong : SR.Format(SR.IO_PathTooLong_Path, path));
30 case 32:
31 return new IOException(string.IsNullOrEmpty(path) ? SR.IO_SharingViolation_NoFileName : SR.Format(SR.IO_SharingViolation_File, path), MakeHRFromErrorCode(errorCode));
32 case 80:
33 if (!string.IsNullOrEmpty(path))
34 {
35 return new IOException(SR.Format(SR.IO_FileExists_Name, path), MakeHRFromErrorCode(errorCode));
36 }
37 break;
38 case 995:
39 return new OperationCanceledException();
40 }
41 return new IOException(string.IsNullOrEmpty(path) ? GetMessage(errorCode) : (GetMessage(errorCode) + " : '" + path + "'"), MakeHRFromErrorCode(errorCode));
42 }
static int MakeHRFromErrorCode(int errorCode)
static string GetMessage(int errorCode)

References System.SR.Format(), System.IO.Win32Marshal.GetMessage(), System.SR.IO_AlreadyExists_Name, System.SR.IO_FileExists_Name, System.SR.IO_FileNotFound, System.SR.IO_FileNotFound_FileName, System.SR.IO_PathNotFound_NoPathName, System.SR.IO_PathNotFound_Path, System.SR.IO_PathTooLong, System.SR.IO_PathTooLong_Path, System.SR.IO_SharingViolation_File, System.SR.IO_SharingViolation_NoFileName, System.IO.Win32Marshal.MakeHRFromErrorCode(), System.SR.UnauthorizedAccess_IODenied_NoPathName, and System.SR.UnauthorizedAccess_IODenied_Path.