MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Runtime.Serialization;5 6namespace System.Management.Automation7{8 /// <summary>9 /// This is a wrapper for exception class10 /// <see cref="System.NotSupportedException"/>11 /// which provides additional information via12 /// <see cref="System.Management.Automation.IContainsErrorRecord"/>.13 /// </summary>14 /// <remarks>15 /// Instances of this exception class are usually generated by the16 /// PowerShell Engine. It is unusual for code outside the PowerShell Engine17 /// to create an instance of this class.18 /// </remarks>19 public class PSNotSupportedException20 : NotSupportedException, IContainsErrorRecord21 {22 #region ctor23 /// <summary>24 /// Initializes a new instance of the PSNotSupportedException class.25 /// </summary>26 /// <returns>Constructed object.</returns>27 public PSNotSupportedException()28 : base()29 {30 }31 32 #region Serialization33 /// <summary>34 /// Initializes a new instance of the PSNotSupportedException class35 /// using data serialized via36 /// <see cref="System.Runtime.Serialization.ISerializable"/>37 /// </summary>38 /// <param name="info">Serialization information.</param>39 /// <param name="context">Streaming context.</param>40 /// <returns>Constructed object.</returns>41 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]42 protected PSNotSupportedException(SerializationInfo info,43 StreamingContext context)44 {45 throw new NotSupportedException();46 }47 48 #endregion Serialization49 50 /// <summary>51 /// Initializes a new instance of the PSNotSupportedException class.52 /// </summary>53 /// <param name="message"></param>54 /// <returns>Constructed object.</returns>55 public PSNotSupportedException(string message)56 : base(message)57 {58 }59 60 /// <summary>61 /// Initializes a new instance of the PSNotSupportedException class.62 /// </summary>63 /// <param name="message"></param>64 /// <param name="innerException"></param>65 /// <returns>Constructed object.</returns>66 public PSNotSupportedException(string message,67 Exception innerException)68 : base(message, innerException)69 {70 }71 #endregion ctor72 73 /// <summary>74 /// Additional information about the error.75 /// </summary>76 /// <value></value>77 /// <remarks>78 /// Note that ErrorRecord.Exception is79 /// <see cref="System.Management.Automation.ParentContainsErrorRecordException"/>.80 /// </remarks>81 public ErrorRecord ErrorRecord82 {83 get84 {85 _errorRecord ??= new ErrorRecord(86 new ParentContainsErrorRecordException(this),87 _errorId,88 ErrorCategory.NotImplemented,89 null);90 91 return _errorRecord;92 }93 }94 95 private ErrorRecord _errorRecord;96 private readonly string _errorId = "NotSupported";97 }98}99 