UIAutomation.UiaProvider.RemoveDrive C# (CSharp) Method

RemoveDrive() protected method

The Windows PowerShell engine calls this method when the Remove-PSDrive cmdlet is run and the path to this provider is specified. This method closes the ODBC connection of the drive.
protected RemoveDrive ( System.Management.Automation.PSDriveInfo drive ) : System.Management.Automation.PSDriveInfo
drive System.Management.Automation.PSDriveInfo The drive to remove.
return System.Management.Automation.PSDriveInfo
        protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
        {
            try{

                // Check if drive object is null.
                if (drive == null)
                {
                    ErrorRecord err =
                        new ErrorRecord(
                          new ArgumentNullException("drive"),
                          "NullDrive",
                          ErrorCategory.InvalidArgument,
                          null);
                    err.ErrorDetails = 
                        new ErrorDetails(
                            "The PSDriveInfo argument is null");
                    //ThrowTerminatingError(err);
                    ThrowTerminatingError(err);

                    // TODO
                    // this.WriteError();
                }

                UiaDriveInfo driveInfo = drive as UiaDriveInfo;
                
                if (driveInfo == null)
                {
                    return null;
                }
                
                driveInfo.Window = null;
                
                return driveInfo;
            }
            catch (Exception e) {
                WriteVerbose(e.Message);
                WriteVerbose("UiaProvider::RemoveDrive()");
                return null;
            }
        } // End RemoveDrive.