protected void ThrowExceptionForHR(string errorText, int hr)
{
// If a severe error has occurred
if (hr < 0)
{
try
{
string s = DsError.GetErrorText(hr);
// If a string is returned, build a com error from it
if (s != null)
{
throw new COMException(s, hr);
}
else
{
// No string, just use standard com error
Marshal.ThrowExceptionForHR(hr);
}
}
catch (Exception ex)
{
throw new Exception(string.Format("{0}{1}", errorText, ex.Message), ex);
}
}
}