Skip to content

Error stream - #1599

Merged
Jason Shirk (lzybkr) merged 3 commits into
masterfrom
error-stream
Aug 2, 2016
Merged

Jason Shirk (lzybkr) merged 3 commits into
masterfrom
error-stream

Conversation

@vors

@vors sergei (vors) commented Aug 2, 2016 •

Copy link
Copy Markdown
Collaborator
  • Resolves issue Error stream and ErrorRecords #1465.

  • Code is rebased on origin/master.

  • Add tests that fail without your changes.

  • N/A: Update all relevant documentation.

    On Linux, it's common to use error stream (2) as an information stream.
    There is no errors in this case, it's just a way to report info.
    When PowerShell redirects error stream, it wraps all output from stream 2
    in NativeCommandError ErrorRecord and subsequent text in
    NativeCommandErrorMessage ErrorRecord.

    That doesn't happen for interactive experience (when there is no
    redirection), but it shows up in logs, scripting and non-console
    powershell hosts (i.e. PowerShell ISE).

    Here we change the formatter, so we are keeping the ErrorRecords
    objects, but we are changing their default representation.

    If it's a NativeCommandError, we don't use the regular ErrorRecord
    formatter. It allows us keep ErrorRecord object,
    but in redirection case it will look exectly like on the screen.

    Also, we are change NativeCommandErrorMessage to use one line per
    ErrorRecord to enable this scenario.

    We also make the error stream messages show-up without red color.

cc Jason Shirk (@lzybkr) James Truher (@JamesWTruher) Bruce Payette (@BrucePay)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You don't actually test this statement directly, you only test the the objects returned have an Exception property.

@lzybkr

Jason Shirk (lzybkr) commented Aug 2, 2016 •

Copy link
Copy Markdown
Contributor

Should we suppress writing to $error as well for stderr output? I think probably. #Closed


Refers to: src/System.Management.Automation/engine/MshCommandRuntime.cs:2919 in 5690b1a. [](commit_id = 5690b1a, deletion_comment = False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IsNativeError [](start = 121, length = 13)

parameters shouldn't start with caps.

@vors

sergei (vors) commented Aug 2, 2016 •

Copy link
Copy Markdown
Collaborator Author

Jason Shirk (@lzybkr) and me agreed, we are not going to change $error variable behavior this time. It's a breaking change (probably from the 2nd bucket), we will discuss it and go thru breaking change process.

Sergei Vorobev added 3 commits August 1, 2016 18:39
Fix #1465

On Linux, it's common to use error stream (2) as an information stream.
There is no errors in this case, it's just a way to report info.
When PowerShell redirects error stream, it wraps all output from stream 2
in NativeCommandError ErrorRecord.

That doesn't happen for interactive experience (when there is no
redirection), but it shows up in logs, scripting and non-console
powershell hosts (i.e. PowerShell ISE).

Here we change the formatter, so we are keeping the ErrorRecords
objects, but we are changing their default representation.

If it's a NativeCommandError, we don't use the regular ErrorRecord
formatter. It allows us keep ErrorRecord object,
but in redirection case it will look exectly like on the screen.

Also, we are change NativeCommandErrorMessage to use one line per
ErrorRecord to enable this scenario.
@lzybkr

Copy link
Copy Markdown
Contributor

:shipit:

@vors

sergei (vors) commented Aug 2, 2016 •

Copy link
Copy Markdown
Collaborator Author

Jason Shirk (@lzybkr) I will leave it for comments a little bit. Please, merge it tomorrow, if there are no objections.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants