ProjectArcade
65 строк · 2.2 Кб
1using System;2using DokanNet.Properties;3
4namespace DokanNet5{
6/// <summary>7/// The dokan exception.8/// </summary>9[Serializable]10public class DokanException : Exception11{12/// <summary>13/// Initializes a new instance of the <see cref="DokanException"/> class with a <see cref="Exception.HResult"/>.14/// </summary>15/// <param name="status">16/// The error status also written to <see cref="Exception.HResult"/>.17/// </param>18internal DokanException(DokanStatus status)19: this(status, GetStatusErrorMessage(status)) { }20
21/// <summary>22/// Initializes a new instance of the <see cref="DokanException"/> class with a <see cref="Exception.HResult"/>.23/// </summary>24/// <param name="status">25/// The error status also written to <see cref="Exception.HResult"/>.26/// </param>27/// <param name="message">28/// The error message.29/// </param>30internal DokanException(DokanStatus status, string message)31: base(message)32{33ErrorStatus = status;34HResult = (int)status;35}36
37private static string GetStatusErrorMessage(DokanStatus status)38{39switch (status)40{41case DokanStatus.Error:42return "Dokan error ";43case DokanStatus.DriveLetterError:44return "Bad drive letter";45case DokanStatus.DriverInstallError:46return "Can't install the Dokan driver";47case DokanStatus.MountError:48return "Can't assign a drive letter or mount point";49case DokanStatus.StartError:50return "Something's wrong with the Dokan driver";51case DokanStatus.MountPointError:52return "Mount point is invalid";53case DokanStatus.VersionError:54return "Version error";55default:56return "Unknown error";57}58}59
60/// <summary>61/// Dokan error status <see cref="DokanStatus"/>.62/// </summary>63public DokanStatus ErrorStatus { get; private set; }64}65}