Skip to content

Improve error message in FileSystemProvider - #9551

Merged
Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
iSazonov:improve-error-message-fileprovider-1
May 8, 2019
Merged

Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
iSazonov:improve-error-message-fileprovider-1

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented May 7, 2019 •

Copy link
Copy Markdown
Collaborator

PR Summary

Improve the error message.

PR Context

Come from #9519 (comment)
Related code:

// First check if we can delete this file when force is not specified.
if (!Force &&
(fileSystemInfo.Attributes & (FileAttributes.Hidden | FileAttributes.System | FileAttributes.ReadOnly)) != 0)
{
string error = StringUtil.Format(FileSystemProviderStrings.PermissionError);
Exception e = new IOException(error);
ErrorDetails errorDetails =
new ErrorDetails(this, "FileSystemProviderStrings",
"CannotRemoveItem",
fileSystemInfo.FullName,
e.Message);
ErrorRecord errorRecord = new ErrorRecord(e, "RemoveFileSystemItemUnAuthorizedAccess", ErrorCategory.PermissionDenied, fileSystemInfo);
errorRecord.ErrorDetails = errorDetails;
WriteError(errorRecord);
return;

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 7, 2019
@iSazonov Ilya (iSazonov) added this to the 7.0.0-preview.1 milestone May 7, 2019
@iSazonov Ilya (iSazonov) self-assigned this May 7, 2019
…trings.resx

Co-Authored-By: iSazonov <darpa@yandex.ru>
@SteveL-MSFT

Copy link
Copy Markdown
Member

The change itself improves the current error message. I just wonder if we should tell the user to use -Force which will work if it's hidden, system, or read-only.

@iSazonov
Ilya (iSazonov) merged commit 3947c9d into PowerShell:master May 8, 2019
@iSazonov
Ilya (iSazonov) deleted the improve-error-message-fileprovider-1 branch May 8, 2019 03:25
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants