Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

Keep stderr as string and don't wrap as ErrorRecord.
This also means that errors from running pwsh.exe within pwsh are now just stderr strings even though they visually look like ErrorRecords so tests had to be changed.
Most customers are likely not running powershell within powershell and expecting errors, but it does mean that try{}catch{} won't work (until we add the enhancement to throw on any stderr).

Fix #3813

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being done in #5189. It shouldn't also be in this PR, I don't think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it, had to change it locally to debug this.

@SteveL-MSFT SteveL-MSFT changed the title [Don't merge] Don't wrap stderr as ErrorRecord Don't wrap stderr as ErrorRecord Oct 21, 2017
@vors
Copy link
Collaborator

vors commented Oct 22, 2017

until we add the enhancement to throw on any stderr

What exactly do you mean? Would any git command throw then?

@SteveL-MSFT
Copy link
Member Author

@vors I was partially thinking of #3415, but thats more for exit codes, but also noting that currently because stderr is wrapped as error record, you can set erroraction = stop and catch it, but with this change you can’t do that anymore.

this.OutputPipe.Add(sendToPipeline);
}

internal void _WriteErrorSkipAllowCheck(object sendToPipeline)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add

Dbg.Assert(record != null, "ProcessReader should ensure that data is ErrorRecord");
record.SetInvocationInfo(this.Command.MyInvocation);
this.commandRuntime._WriteErrorSkipAllowCheck(record, isNativeError: true);
this.commandRuntime._WriteErrorSkipAllowCheck(outputValue.Data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment stating that it is the intent to not wrap native stderror in an ErrorRecord.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add

{
$ErrorActionPreference = $origEA
}
It "Verify Validate Dollar Error Populated should be in stderr" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also have a test for stream redirection to output?
$err = & $powershell -noprofile -command { wgwg-wrwrhqwrhrh35h3h3} 2>&1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add that

Copy link
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vors vors removed their request for review October 25, 2017 05:59
/// The Cmdlet should generally just allow PipelineStoppedException
/// to percolate up to the caller of ProcessRecord etc.
/// </exception>
internal void _WriteErrorSkipAllowCheck(object sendToPipeline)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name this WriteNativeCommandErrorSkipAllowCheck instead?

record.SetInvocationInfo(this.Command.MyInvocation);
this.commandRuntime._WriteErrorSkipAllowCheck(record, isNativeError: true);
// write stderr as string instead of as ErrorRecord
this.commandRuntime._WriteErrorSkipAllowCheck(outputValue.Data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputValue.Data is still an ErrorRecord - right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, outputValue.Data is still an ErrorRecord. I'll need to rework this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants