GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable nullable: System.Management.Automation.IContainsErrorRecord by powercode · Pull Request #14166 · PowerShell/PowerShell

Conversation

@powercode

@powercode Staffan Gustafsson (powercode) commented Nov 19, 2020

Copy link
Copy Markdown
Collaborator

Tracking issue: #12631.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@powercode
Enable nullable: System.Management.Automation.IContainsErrorRecord
a77f340
@ghost ghost assigned Ilya (iSazonov) Nov 19, 2020
@iSazonov
Ilya (iSazonov) requested a review from Rain Sallow (/u/ta11ow) (vexx32) November 20, 2020 04:34
iSazonov
Ilya (iSazonov) requested changes Nov 20, 2020
View reviewed changes
Comment thread src/System.Management.Automation/engine/ErrorPackage.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/ErrorPackage.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 20, 2020
@iSazonov Ilya (iSazonov) added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log and removed CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log labels Nov 20, 2020
@powercode

Staffan Gustafsson (powercode) commented Nov 20, 2020

Copy link
Copy Markdown
Collaborator Author

The checks I see are of the type

 var icer = exception as IContainsErrorRecord;
if (icer == null)...

But that is just checking for the interface.

        /// <summary>
        /// Encode exception.
        /// </summary>
        private static PSObject EncodeException(Exception exception)
        {
            // We are encoding exceptions as ErrorRecord objects because exceptions written
            // to the wire are lost during serialization. By sending across ErrorRecord objects
            // we are able to preserve the exception as well as the stack trace.

            ErrorRecord errorRecord = null;
            IContainsErrorRecord containsErrorRecord = exception as IContainsErrorRecord;
            if (containsErrorRecord == null)
            {
                // If this is a .NET exception then wrap in an ErrorRecord.
                errorRecord = new ErrorRecord(exception, "RemoteHostExecutionException", ErrorCategory.NotSpecified, null);
            }
            else
            {
                // Exception inside the error record is ParentContainsErrorRecordException which
                // doesn't have stack trace. Replace it with top level exception.
                errorRecord = containsErrorRecord.ErrorRecord;
                errorRecord = new ErrorRecord(errorRecord, exception);
            }

            PSObject errorRecordPSObject = RemotingEncoder.CreateEmptyPSObject();
            errorRecord.ToPSObjectForRemoting(errorRecordPSObject);
            return errorRecordPSObject;
        }

And

        public ErrorRecord(ErrorRecord errorRecord,
                             Exception replaceParentContainsErrorRecordException)
        {
            if (errorRecord == null)
            {
                throw new PSArgumentNullException(nameof(errorRecord));
            }
}

Clearly, the expectation is that it is non-null.

I don't think the checks you see for null are what you think they are.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 20, 2020
@powercode
Removing empty lines before and after pragma
a4da1f2
@powercode

Staffan Gustafsson (powercode) commented Nov 20, 2020

Copy link
Copy Markdown
Collaborator Author

I think those checks are just extra precautions since we haven't had a language mechanism to help us with this.
So devs add safeguards.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vexx32
Rain Sallow (/u/ta11ow) (vexx32) approved these changes Nov 20, 2020
View reviewed changes
@powercode
Removing whitespace before/after nullable pragma
1228bc4
iSazonov
Ilya (iSazonov) approved these changes Nov 21, 2020
View reviewed changes
@iSazonov
Ilya (iSazonov) requested review from Dongbo Wang (daxian-dbw) and Rob Holt (rjmholt) November 21, 2020 14:03
@ghost ghost added the Review - Needed The PR is being reviewed label Nov 29, 2020
@ghost

Deleted user (ghost) commented Nov 29, 2020

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Ilya (iSazonov) merged commit 33ce474 into PowerShell:master Jan 9, 2021
@ghost ghost removed the Review - Needed The PR is being reviewed label Jan 9, 2021
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.3 milestone Jan 9, 2021
@powercode
Staffan Gustafsson (powercode) deleted the nullable/IContainsErrorRecord branch January 13, 2021 15:28
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@powercode
Enable nullable: System.Management.Automation.IContainsErrorRecord (P…
26b7b88
…owerShell#14166)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov approved these changes
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw
@rjmholt Rob Holt (rjmholt) Awaiting requested review from rjmholt
+1 more reviewer
@vexx32 Rain Sallow (/u/ta11ow) (vexx32) vexx32 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iSazonov Ilya (iSazonov)

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Milestone

7.2.0-preview.3

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@powercode @iSazonov @vexx32
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.