System.Security.AccessControl.RegistrySecurity._HandleErrorCode C# (CSharp) Method

_HandleErrorCode() private method

private _HandleErrorCode ( int errorCode, string name, SafeHandle handle, object context ) : Exception
errorCode int
name string
handle System.Runtime.InteropServices.SafeHandle
context object
return Exception
        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;
        }