-
Notifications
You must be signed in to change notification settings - Fork 235
Make sure ErrorRecords go to Error stream #1201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure ErrorRecords go to Error stream #1201
Conversation
|
||
this.WriteError(message); | ||
var psObject = PSObject.AsPSObject(e.ErrorRecord); | ||
s_writeStreamProperty.SetValue(psObject, s_errorStreamValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might also be possible to bake these two reflection values into a closed delegate, but it's not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
talked offline... since the Enum type is not public, we'll defer this for now as it's more work than it's worth.
I've added a bit more logic to make sure that pre-7 it's also being added to the ErrorStream. This is important for the legacy console experience which would render the errors as white instead of red without the note property. |
} | ||
else | ||
{ | ||
var note = new PSNoteProperty("writeErrorStream", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var note = new PSNoteProperty("writeErrorStream", true); | |
var note = new PSNoteProperty("WriteErrorStream", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got that from PowerShell but since it seems to be case insensitive I can make this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May as well use what PowerShell uses. Strange they did it that way
Issues
======
- Added 1
See the complete overview on Codacy |
@daxian-dbw found a strange behavior in the Console's PSHost where empty lines are skipped in
WriteErrorLine
.He also discovered that errors were not going into the Error stream unless they have the
WriteStream
property set toError
.. which sadly can only be done via reflection.This leverages that so that errors are printed out correctly instead of with this ugly line:

Also actually uses PowerShell to format parse errors correctly.