Add more information to job process failure error (#7251)

This commit is contained in:
Robert Holt
2018-07-12 08:06:07 +05:00
committed by Ilya
parent 79d20a1873
commit 6a66a6e0f0
2 changed files with 37 additions and 3 deletions
@@ -708,8 +708,32 @@ namespace System.Management.Automation.Remoting.Client
//
stdInWriter.StopWriting();
}
PSRemotingTransportException psrte = new PSRemotingTransportException(PSRemotingErrorId.IPCServerProcessExited,
RemotingErrorIdStrings.IPCServerProcessExited);
// Try to get details about why the process exited
// and if they're not available, give information as to why
string processDiagnosticMessage;
try
{
var jobProcess = (Process)sender;
processDiagnosticMessage = StringUtil.Format(
RemotingErrorIdStrings.ProcessExitInfo,
jobProcess.ExitCode,
jobProcess.StandardOutput.ReadToEnd(),
jobProcess.StandardError.ReadToEnd());
}
catch (Exception exception)
{
processDiagnosticMessage = StringUtil.Format(
RemotingErrorIdStrings.ProcessInfoNotRecoverable,
exception.Message);
}
string exitErrorMsg = StringUtil.Format(
RemotingErrorIdStrings.IPCServerProcessExited,
processDiagnosticMessage);
var psrte = new PSRemotingTransportException(
PSRemotingErrorId.IPCServerProcessExited,
exitErrorMsg);
RaiseErrorHandler(new TransportErrorOccuredEventArgs(psrte, transportMethod));
}
@@ -794,7 +794,7 @@ Do you want to continue?</value>
<value>The background process reported an error with the following message: {0}.</value>
</data>
<data name="IPCServerProcessExited" xml:space="preserve">
<value>The background process closed or ended abnormally.</value>
<value>The background process closed or ended abnormally: {0}.</value>
</data>
<data name="IPCErrorProcessingServerData" xml:space="preserve">
<value>There is an error processing data from the background process. Error reported: {0}.</value>
@@ -1657,4 +1657,14 @@ All WinRM sessions connected to PowerShell session configurations, such as Micro
<data name="WSManClientDllNotAvailable" xml:space="preserve">
<value>This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.</value>
</data>
<data name="ProcessExitInfo" xml:space="preserve">
<value>
Exit code: {0}
Stdout: '{1}'
Stderr: '{2}'
</value>
</data>
<data name="ProcessInfoNotRecoverable" xml:space="preserve">
<value>Information about the process could not be read: '{0}'.</value>
</data>
</root>