private static Exception _HandleErrorCode(int errorCode, string name, SafeHandle handle, object context)
{
Exception exception = null;
switch (errorCode)
{
case Interop.Errors.ERROR_FILE_NOT_FOUND:
exception = new IOException(SR.Format(SR.Arg_RegKeyNotFound, errorCode));
break;
case Interop.Errors.ERROR_INVALID_NAME:
exception = new ArgumentException(SR.Format(SR.Arg_RegInvalidKeyName, nameof(name)));
break;
case Interop.Errors.ERROR_INVALID_HANDLE:
exception = new ArgumentException(SR.AccessControl_InvalidHandle);
break;
default:
break;
}
return exception;
}