internal PSRemotingTransportRedirectException( Exception innerException, PSRemotingErrorId errorId, params object[] args) : base(innerException, errorId, args) { }
internal static TransportErrorOccuredEventArgs ConstructTransportErrorEventArgs( IntPtr wsmanAPIHandle, IntPtr wsmanSessionHandle, WSManNativeApi.WSManError errorStruct, TransportMethodEnum transportMethodReportingError, PSRemotingErrorId errorResourceID, params object[] resourceArgs) { PSRemotingTransportException e; if (errorStruct.errorCode == -2144108135) { string sessionOptionAsString = WSManNativeApi.WSManGetSessionOptionAsString(wsmanSessionHandle, WSManNativeApi.WSManSessionOption.WSMAN_OPTION_REDIRECT_LOCATION); string str = WSManTransportManagerUtils.ParseEscapeWSManErrorMessage(WSManNativeApi.WSManGetErrorMessage(wsmanAPIHandle, errorStruct.errorCode)).Trim(); e = (PSRemotingTransportException) new PSRemotingTransportRedirectException(sessionOptionAsString, PSRemotingErrorId.URIEndPointNotResolved, new object[2] { (object)str, (object)sessionOptionAsString }); } else { e = new PSRemotingTransportException(PSRemotingErrorId.TroubleShootingHelpTopic, new object[1] { (object)PSRemotingErrorInvariants.FormatResourceString(errorResourceID, resourceArgs) }); e.TransportMessage = WSManTransportManagerUtils.ParseEscapeWSManErrorMessage(WSManNativeApi.WSManGetErrorMessage(wsmanAPIHandle, errorStruct.errorCode)); } e.ErrorCode = errorStruct.errorCode; return(new TransportErrorOccuredEventArgs(e, transportMethodReportingError)); }
internal PSRemotingDataStructureException( Exception innerException, PSRemotingErrorId errorId, params object[] args) : base(PSRemotingErrorInvariants.FormatResourceString(errorId, args), innerException) { this.SetDefaultErrorRecord(); }
private RemoteHostCall ConstructWarningMessageForSecureString( string computerName, PSRemotingErrorId errorId) { return(new RemoteHostCall(-100L, RemoteHostMethodId.WriteWarningLine, new object[1] { (object)PSRemotingErrorInvariants.FormatResourceString(errorId, (object)computerName.ToUpper(CultureInfo.CurrentCulture)) })); }
private RemoteRunspace GetRunspaceMatchingSessionId(int sessionId) { Predicate <PSSession> condition = info => info.Id == sessionId; PSRemotingErrorId remoteRunspaceNotAvailableForSpecifiedSessionId = PSRemotingErrorId.RemoteRunspaceNotAvailableForSpecifiedSessionId; PSRemotingErrorId remoteRunspaceHasMultipleMatchesForSpecifiedSessionId = PSRemotingErrorId.RemoteRunspaceHasMultipleMatchesForSpecifiedSessionId; string tooFewResourceString = RemotingErrorIdStrings.RemoteRunspaceNotAvailableForSpecifiedSessionId; string tooManyResourceString = RemotingErrorIdStrings.RemoteRunspaceHasMultipleMatchesForSpecifiedSessionId; return(this.GetRunspaceMatchingCondition(condition, remoteRunspaceNotAvailableForSpecifiedSessionId, remoteRunspaceHasMultipleMatchesForSpecifiedSessionId, tooFewResourceString, tooManyResourceString, sessionId)); }
private RemoteRunspace GetRunspaceMatchingName(string name) { Predicate <PSSession> condition = info => info.Name.Equals(name, StringComparison.OrdinalIgnoreCase); PSRemotingErrorId remoteRunspaceNotAvailableForSpecifiedName = PSRemotingErrorId.RemoteRunspaceNotAvailableForSpecifiedName; PSRemotingErrorId remoteRunspaceHasMultipleMatchesForSpecifiedName = PSRemotingErrorId.RemoteRunspaceHasMultipleMatchesForSpecifiedName; string tooFewResourceString = RemotingErrorIdStrings.RemoteRunspaceNotAvailableForSpecifiedName; string tooManyResourceString = RemotingErrorIdStrings.RemoteRunspaceHasMultipleMatchesForSpecifiedName; return(this.GetRunspaceMatchingCondition(condition, remoteRunspaceNotAvailableForSpecifiedName, remoteRunspaceHasMultipleMatchesForSpecifiedName, tooFewResourceString, tooManyResourceString, name)); }
private bool CheckJobCanBeRemoved( Job job, string parameterName, PSRemotingErrorId id, params object[] list) { using (JobCmdletBase.tracer.TraceMethod()) { if (job.IsFinishedState(job.JobStateInfo.State)) { return(true); } this.WriteError(new ErrorRecord((Exception) new ArgumentException(PSRemotingErrorInvariants.FormatResourceString(id, list), parameterName), "JobObjectNotFinishedCannotBeRemoved", ErrorCategory.InvalidOperation, (object)job)); return(false); } }
private RemoteRunspace GetRunspaceMatchingCondition(Predicate <PSSession> condition, PSRemotingErrorId tooFew, PSRemotingErrorId tooMany, string tooFewResourceString, string tooManyResourceString, object errorArgument) { List <PSSession> list = base.RunspaceRepository.Runspaces.FindAll(condition); RemoteRunspace runspace = null; if (list.Count == 0) { this.WriteInvalidArgumentError(tooFew, tooFewResourceString, errorArgument); return(runspace); } if (list.Count > 1) { this.WriteInvalidArgumentError(tooMany, tooManyResourceString, errorArgument); return(runspace); } return((RemoteRunspace)list[0].Runspace); }
/// <summary> /// This constructor takes an redirect URI, error id and optional parameters. /// </summary> /// <param name="redirectLocation"> /// String specifying a redirect location. /// </param> /// <param name="errorId"> /// The error id in the base resource file. /// </param> /// <param name="resourceString"> /// The resource string in the base resource file. /// </param> /// <param name="args"> /// Optional parameters required to format the resource string. /// </param> internal PSRemotingTransportRedirectException(string redirectLocation, PSRemotingErrorId errorId, string resourceString, params object[] args) : base(errorId, resourceString, args) { RedirectLocation = redirectLocation; }
internal static string FormatResourceString(PSRemotingErrorId messageId, params object[] args) => ResourceManagerCache.FormatResourceString("RemotingErrorIdStrings", messageId.ToString(), args);
/// <summary> /// This constructor takes an error id and optional parameters. /// </summary> /// <param name="errorId"> /// The error id in the base resource file. /// </param> /// <param name="resourceString"> /// The resource string in the base resource file. /// </param> /// <param name="args"> /// Optional parameters required to format the resource string. /// </param> internal PSRemotingTransportException(PSRemotingErrorId errorId, string resourceString, params object[] args) : base(PSRemotingErrorInvariants.FormatResourceString(resourceString, args)) { SetDefaultErrorRecord(); _errorCode = (int)errorId; }
private RemoteRunspace GetRunspaceMatchingCondition(Predicate<PSSession> condition, PSRemotingErrorId tooFew, PSRemotingErrorId tooMany, string tooFewResourceString, string tooManyResourceString, object errorArgument) { List<PSSession> list = base.RunspaceRepository.Runspaces.FindAll(condition); RemoteRunspace runspace = null; if (list.Count == 0) { this.WriteInvalidArgumentError(tooFew, tooFewResourceString, errorArgument); return runspace; } if (list.Count > 1) { this.WriteInvalidArgumentError(tooMany, tooManyResourceString, errorArgument); return runspace; } return (RemoteRunspace) list[0].Runspace; }
internal string GetMessage(PSRemotingErrorId errorId, params object[] args) => args == null?ResourceManagerCache.GetResourceString("RemotingErrorIdStrings", errorId.ToString()) : ResourceManagerCache.FormatResourceString("RemotingErrorIdStrings", errorId.ToString(), args);
internal string GetMessage(PSRemotingErrorId errorId) => this.GetMessage(errorId, (object[])null);
private void WriteInvalidArgumentError(PSRemotingErrorId errorId, string resourceString, object errorArgument) { string message = base.GetMessage(resourceString, new object[] { errorArgument }); base.WriteError(new ErrorRecord(new ArgumentException(message), errorId.ToString(), ErrorCategory.InvalidArgument, errorArgument)); }
/// <summary> /// Write invalid argument error. /// </summary> private void WriteInvalidArgumentError(PSRemotingErrorId errorId, string resourceString, object errorArgument) { String message = GetMessage(resourceString, errorArgument); WriteError(new ErrorRecord(new ArgumentException(message), errorId.ToString(), ErrorCategory.InvalidArgument, errorArgument)); }
/// <summary> /// Get runspace matching condition. /// </summary> private RemoteRunspace GetRunspaceMatchingCondition( Predicate<PSSession> condition, PSRemotingErrorId tooFew, PSRemotingErrorId tooMany, string tooFewResourceString, string tooManyResourceString, object errorArgument) { // Find matches. List<PSSession> matches = this.RunspaceRepository.Runspaces.FindAll(condition); // Validate. RemoteRunspace remoteRunspace = null; if (matches.Count == 0) { WriteInvalidArgumentError(tooFew, tooFewResourceString, errorArgument); } else if (matches.Count > 1) { WriteInvalidArgumentError(tooMany, tooManyResourceString, errorArgument); } else { remoteRunspace = (RemoteRunspace)matches[0].Runspace; Dbg.Assert(remoteRunspace != null, "Expected remoteRunspace != null"); } return remoteRunspace; }