MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections.ObjectModel;5using System.Management.Automation.Internal;6using System.Runtime.Serialization;7 8namespace System.Management.Automation9{10 /// <summary>11 /// An exception that wraps all exceptions that are thrown by providers. This allows12 /// callers of the provider APIs to be able to catch a single exception no matter13 /// what any of the various providers may have thrown.14 /// </summary>15 public class ProviderInvocationException : RuntimeException16 {17 #region Constructors18 /// <summary>19 /// Constructs a ProviderInvocationException.20 /// </summary>21 public ProviderInvocationException() : base()22 {23 }24 25 /// <summary>26 /// Constructs a ProviderInvocationException using serialized data.27 /// </summary>28 /// <param name="info">29 /// serialization information30 /// </param>31 /// <param name="context">32 /// streaming context33 /// </param>34 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]35 protected ProviderInvocationException(36 SerializationInfo info,37 StreamingContext context)38 {39 throw new NotSupportedException();40 }41 42 /// <summary>43 /// Constructs a ProviderInvocationException with a message.44 /// </summary>45 /// <param name="message">46 /// The message for the exception.47 /// </param>48 public ProviderInvocationException(string message)49 : base(message)50 {51 _message = message;52 }53 54 /// <summary>55 /// Constructs a ProviderInvocationException with provider information and an inner exception.56 /// </summary>57 /// <param name="provider">58 /// Information about the provider to be used in formatting the message.59 /// </param>60 /// <param name="innerException">61 /// The inner exception for this exception.62 /// </param>63 internal ProviderInvocationException(ProviderInfo provider, Exception innerException)64 : base(RuntimeException.RetrieveMessage(innerException), innerException)65 {66 _message = base.Message;67 _providerInfo = provider;68 69 if (innerException is IContainsErrorRecord icer && icer.ErrorRecord != null)70 {71 _errorRecord = new ErrorRecord(icer.ErrorRecord, innerException);72 }73 else74 {75 _errorRecord = new ErrorRecord(76 innerException,77 "ErrorRecordNotSpecified",78 ErrorCategory.InvalidOperation,79 null);80 }81 }82 83 /// <summary>84 /// Constructs a ProviderInvocationException with provider information and an85 /// ErrorRecord.86 /// </summary>87 /// <param name="provider">88 /// Information about the provider to be used in formatting the message.89 /// </param>90 /// <param name="errorRecord">91 /// Detailed error information92 /// </param>93 internal ProviderInvocationException(ProviderInfo provider, ErrorRecord errorRecord)94 : base(RuntimeException.RetrieveMessage(errorRecord),95 RuntimeException.RetrieveException(errorRecord))96 {97 ArgumentNullException.ThrowIfNull(errorRecord);98 99 _message = base.Message;100 _providerInfo = provider;101 _errorRecord = errorRecord;102 }103 104 /// <summary>105 /// Constructs a ProviderInvocationException with a message106 /// and inner exception.107 /// </summary>108 /// <param name="message">109 /// The message for the exception.110 /// </param>111 /// <param name="innerException">112 /// The inner exception for this exception.113 /// </param>114 public ProviderInvocationException(string message, Exception innerException)115 : base(message, innerException)116 {117 _message = message;118 }119 120 /// <summary>121 /// Constructs a ProviderInvocationException.122 /// </summary>123 /// <param name="errorId">124 /// This string will be used to construct the FullyQualifiedErrorId,125 /// which is a global identifier of the error condition. Pass a126 /// non-empty string which is specific to this error condition in127 /// this context.128 /// </param>129 /// <param name="resourceStr">130 /// This string is the message template string.131 /// </param>132 /// <param name="provider">133 /// The provider information used to format into the message.134 /// </param>135 /// <param name="path">136 /// The path that was being processed when the exception occurred.137 /// </param>138 /// <param name="innerException">139 /// The exception that was thrown by the provider.140 /// </param>141 internal ProviderInvocationException(142 string errorId,143 string resourceStr,144 ProviderInfo provider,145 string path,146 Exception innerException)147 : this(errorId, resourceStr, provider, path, innerException, true)148 {149 }150 151 /// <summary>152 /// Constructor to make it easy to wrap a provider exception.153 /// </summary>154 /// <param name="errorId">155 /// This string will be used to construct the FullyQualifiedErrorId,156 /// which is a global identifier of the error condition. Pass a157 /// non-empty string which is specific to this error condition in158 /// this context.159 /// </param>160 /// <param name="resourceStr">161 /// This is the message template string162 /// </param>163 /// <param name="provider">164 /// The provider information used to format into the message.165 /// </param>166 /// <param name="path">167 /// The path that was being processed when the exception occurred.168 /// </param>169 /// <param name="innerException">170 /// The exception that was thrown by the provider.171 /// </param>172 /// <param name="useInnerExceptionMessage">173 /// If true, the message from the inner exception will be used if the exception contains174 /// an ErrorRecord. If false, the error message retrieved using the errorId will be used.175 /// </param>176 internal ProviderInvocationException(177 string errorId,178 string resourceStr,179 ProviderInfo provider,180 string path,181 Exception innerException,182 bool useInnerExceptionMessage)183 : base(184 RetrieveMessage(errorId, resourceStr, provider, path, innerException),185 innerException)186 {187 _providerInfo = provider;188 189 _message = base.Message;190 191 Exception errorRecordException = null;192 if (useInnerExceptionMessage)193 {194 errorRecordException = innerException;195 }196 else197 {198 errorRecordException = new ParentContainsErrorRecordException(this);199 }200 201 if (innerException is IContainsErrorRecord icer && icer.ErrorRecord != null)202 {203 _errorRecord = new ErrorRecord(icer.ErrorRecord, errorRecordException);204 }205 else206 {207 _errorRecord = new ErrorRecord(208 errorRecordException,209 errorId,210 ErrorCategory.InvalidOperation,211 null);212 }213 }214 #endregion Constructors215 216 #region Properties217 /// <summary>218 /// Gets the provider information of the provider that threw an exception.219 /// </summary>220 public ProviderInfo ProviderInfo { get { return _providerInfo; } }221 222 [NonSerialized]223 internal ProviderInfo _providerInfo;224 225 /// <summary>226 /// Gets the error record.227 /// </summary>228 public override ErrorRecord ErrorRecord229 {230 get231 {232 _errorRecord ??= new ErrorRecord(233 new ParentContainsErrorRecordException(this),234 "ProviderInvocationException",235 ErrorCategory.NotSpecified,236 null);237 238 return _errorRecord;239 }240 }241 242 [NonSerialized]243 private ErrorRecord _errorRecord;244 #endregion Properties245 246 #region Private/Internal247 private static string RetrieveMessage(248 string errorId,249 string resourceStr,250 ProviderInfo provider,251 string path,252 Exception innerException)253 {254 if (innerException == null)255 {256 Diagnostics.Assert(false,257 "ProviderInvocationException.RetrieveMessage needs innerException");258 return string.Empty;259 }260 261 if (string.IsNullOrEmpty(errorId))262 {263 Diagnostics.Assert(false,264 "ProviderInvocationException.RetrieveMessage needs errorId");265 return RuntimeException.RetrieveMessage(innerException);266 }267 268 if (provider == null)269 {270 Diagnostics.Assert(false,271 "ProviderInvocationException.RetrieveMessage needs provider");272 return RuntimeException.RetrieveMessage(innerException);273 }274 275 string format = resourceStr;276 if (string.IsNullOrEmpty(format))277 {278 Diagnostics.Assert(false,279 "ProviderInvocationException.RetrieveMessage bad errorId " + errorId);280 return RuntimeException.RetrieveMessage(innerException);281 }282 283 string result = null;284 285 if (path == null)286 {287 result =288 string.Format(289 System.Globalization.CultureInfo.CurrentCulture,290 format,291 provider.Name,292 RuntimeException.RetrieveMessage(innerException));293 }294 else295 {296 result =297 string.Format(298 System.Globalization.CultureInfo.CurrentCulture,299 format,300 provider.Name,301 path,302 RuntimeException.RetrieveMessage(innerException));303 }304 305 return result;306 }307 308 /// <summary>309 /// Gets the exception message.310 /// </summary>311 public override string Message312 {313 get { return (string.IsNullOrEmpty(_message)) ? base.Message : _message; }314 }315 316 [NonSerialized]317 private readonly string _message /* = null */;318 319 #endregion Private/Internal320 }321 322 /// <summary>323 /// Categories of session state objects, used by SessionStateException.324 /// </summary>325 public enum SessionStateCategory326 {327 /// <summary>328 /// Used when an exception is thrown accessing a variable.329 /// </summary>330 Variable = 0,331 332 /// <summary>333 /// Used when an exception is thrown accessing an alias.334 /// </summary>335 Alias = 1,336 337 /// <summary>338 /// Used when an exception is thrown accessing a function.339 /// </summary>340 Function = 2,341 342 /// <summary>343 /// Used when an exception is thrown accessing a filter.344 /// </summary>345 Filter = 3,346 347 /// <summary>348 /// Used when an exception is thrown accessing a drive.349 /// </summary>350 Drive = 4,351 352 /// <summary>353 /// Used when an exception is thrown accessing a Cmdlet Provider.354 /// </summary>355 CmdletProvider = 5,356 357 /// <summary>358 /// Used when an exception is thrown manipulating the PowerShell language scopes.359 /// </summary>360 Scope = 6,361 362 /// <summary>363 /// Used when generically accessing any type of command...364 /// </summary>365 Command = 7,366 367 /// <summary>368 /// Other resources not covered by the previous categories...369 /// </summary>370 Resource = 8,371 372 /// <summary>373 /// Used when an exception is thrown accessing a cmdlet.374 /// </summary>375 Cmdlet = 9,376 }377 378 /// <summary>379 /// SessionStateException represents an error working with380 /// session state objects: variables, aliases, functions, filters,381 /// drives, or providers.382 /// </summary>383 public class SessionStateException : RuntimeException384 {385 #region ctor386 /// <summary>387 /// Constructs a SessionStateException.388 /// </summary>389 /// <param name="itemName">Name of session state object.</param>390 /// <param name="sessionStateCategory">Category of session state object.</param>391 /// <param name="resourceStr">This string is the message template string.</param>392 /// <param name="errorIdAndResourceId">393 /// This string is the ErrorId passed to the ErrorRecord, and is also394 /// the resourceId used to look up the message template string in395 /// SessionStateStrings.txt.396 /// </param>397 /// <param name="errorCategory">ErrorRecord.CategoryInfo.Category.</param>398 /// <param name="messageArgs">399 /// Additional insertion strings used to construct the message.400 /// Note that itemName is always the first insertion string.401 /// </param>402 internal SessionStateException(403 string itemName,404 SessionStateCategory sessionStateCategory,405 string errorIdAndResourceId,406 string resourceStr,407 ErrorCategory errorCategory,408 params object[] messageArgs)409 : base(BuildMessage(itemName, resourceStr, messageArgs))410 {411 _itemName = itemName;412 _sessionStateCategory = sessionStateCategory;413 _errorId = errorIdAndResourceId;414 _errorCategory = errorCategory;415 }416 417 /// <summary>418 /// Constructs a SessionStateException.419 /// </summary>420 public SessionStateException()421 : base()422 {423 }424 425 /// <summary>426 /// Constructs a SessionStateException.427 /// </summary>428 /// <param name="message">429 /// The message used in the exception.430 /// </param>431 public SessionStateException(string message)432 : base(message)433 {434 }435 436 /// <summary>437 /// Constructs a SessionStateException.438 /// </summary>439 /// <param name="message">440 /// The message used in the exception.441 /// </param>442 /// <param name="innerException">443 /// The exception that caused the error.444 /// </param>445 public SessionStateException(string message,446 Exception innerException)447 : base(message, innerException)448 {449 }450 #endregion ctor451/// <summary>452 /// Constructs a SessionStateException using serialized data.453 /// </summary>454 /// <param name="info">Serialization information.</param>455 /// <param name="context">Streaming context.</param>456 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]457 protected SessionStateException(SerializationInfo info,458 StreamingContext context)459 {460 throw new NotSupportedException();461 }462 463 #region Properties464 /// <summary>465 /// Gets the error record information for this exception.466 /// </summary>467 public override ErrorRecord ErrorRecord468 {469 get470 {471 _errorRecord ??= new ErrorRecord(472 new ParentContainsErrorRecordException(this),473 _errorId,474 _errorCategory,475 _itemName);476 477 return _errorRecord;478 }479 }480 481 private ErrorRecord _errorRecord;482 483 /// <summary>484 /// Gets the name of session state object the error occurred on.485 /// </summary>486 public string ItemName487 {488 get { return _itemName; }489 }490 491 private readonly string _itemName = string.Empty;492 493 /// <summary>494 /// Gets the category of session state object the error occurred on.495 /// </summary>496 public SessionStateCategory SessionStateCategory497 {498 get { return _sessionStateCategory; }499 }500 501 private readonly SessionStateCategory _sessionStateCategory = SessionStateCategory.Variable;502 #endregion Properties503 504 #region Private505 private readonly string _errorId = "SessionStateException";506 private readonly ErrorCategory _errorCategory = ErrorCategory.InvalidArgument;507 508 private static string BuildMessage(509 string itemName,510 string resourceStr,511 params object[] messageArgs)512 {513 object[] a;514 if (messageArgs != null && messageArgs.Length > 0)515 {516 a = new object[messageArgs.Length + 1];517 a[0] = itemName;518 messageArgs.CopyTo(a, 1);519 }520 else521 {522 a = new object[1];523 a[0] = itemName;524 }525 526 return StringUtil.Format(resourceStr, a);527 }528 #endregion Private529 }530 531 /// <summary>532 /// SessionStateUnauthorizedAccessException occurs when533 /// a change to a session state object cannot be completed534 /// because the object is read-only or constant, or because535 /// an object which is declared constant cannot be removed536 /// or made non-constant.537 /// </summary>538 public class SessionStateUnauthorizedAccessException : SessionStateException539 {540 #region ctor541 /// <summary>542 /// Constructs a SessionStateUnauthorizedAccessException.543 /// </summary>544 /// <param name="itemName">545 /// The name of the session state object the error occurred on.546 /// </param>547 /// <param name="sessionStateCategory">548 /// The category of session state object.549 /// </param>550 /// <param name="errorIdAndResourceId">551 /// This string is the ErrorId passed to the ErrorRecord, and is also552 /// the resourceId used to look up the message template string in553 /// SessionStateStrings.txt.554 /// </param>555 /// <param name="resourceStr">556 /// This string is the ErrorId passed to the ErrorRecord, and is also557 /// the resourceId used to look up the message template string in558 /// SessionStateStrings.txt.559 /// </param>560 internal SessionStateUnauthorizedAccessException(561 string itemName,562 SessionStateCategory sessionStateCategory,563 string errorIdAndResourceId,564 string resourceStr565 )566 : base(itemName, sessionStateCategory,567 errorIdAndResourceId, resourceStr, ErrorCategory.WriteError)568 {569 }570 571 /// <summary>572 /// Constructs a SessionStateUnauthorizedAccessException using serialized data.573 /// </summary>574 /// <param name="info">Serialization information.</param>575 /// <param name="context">Streaming context.</param>576 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]577 protected SessionStateUnauthorizedAccessException(578 SerializationInfo info,579 StreamingContext context)580 {581 throw new NotSupportedException();582 }583 584 /// <summary>585 /// Constructs a SessionStateUnauthorizedAccessException.586 /// </summary>587 public SessionStateUnauthorizedAccessException()588 : base()589 {590 }591 592 /// <summary>593 /// Constructs a SessionStateUnauthorizedAccessException.594 /// </summary>595 /// <param name="message">596 /// The message used by the exception.597 /// </param>598 public SessionStateUnauthorizedAccessException(string message)599 : base(message)600 {601 }602 603 /// <summary>604 /// Constructs a SessionStateUnauthorizedAccessException.605 /// </summary>606 /// <param name="message">607 /// The message used by the exception.608 /// </param>609 /// <param name="innerException">610 /// The exception that caused the error.611 /// </param>612 public SessionStateUnauthorizedAccessException(string message,613 Exception innerException)614 : base(message, innerException)615 {616 }617 #endregion ctor618 }619 620 /// <summary>621 /// ProviderNotFoundException occurs when no provider can be found622 /// with the specified name.623 /// </summary>624 public class ProviderNotFoundException : SessionStateException625 {626 #region ctor627 /// <summary>628 /// Constructs a ProviderNotFoundException.629 /// </summary>630 /// <param name="itemName">631 /// The name of provider that could not be found.632 /// </param>633 /// <param name="sessionStateCategory">634 /// The category of session state object635 /// </param>636 /// <param name="errorIdAndResourceId">637 /// This string is the ErrorId passed to the ErrorRecord, and is also638 /// the resourceId used to look up the message template string in639 /// SessionStateStrings.txt.640 /// </param>641 /// <param name="resourceStr">642 /// This string is the message template string643 /// </param>644 /// <param name="messageArgs">645 /// Additional arguments to build the message from.646 /// </param>647 internal ProviderNotFoundException(648 string itemName,649 SessionStateCategory sessionStateCategory,650 string errorIdAndResourceId,651 string resourceStr,652 params object[] messageArgs)653 : base(654 itemName,655 sessionStateCategory,656 errorIdAndResourceId,657 resourceStr,658 ErrorCategory.ObjectNotFound,659 messageArgs)660 {661 }662 663 /// <summary>664 /// Constructs a ProviderNotFoundException.665 /// </summary>666 public ProviderNotFoundException()667 : base()668 {669 }670 671 /// <summary>672 /// Constructs a ProviderNotFoundException.673 /// </summary>674 /// <param name="message">675 /// The messaged used by the exception.676 /// </param>677 public ProviderNotFoundException(string message)678 : base(message)679 {680 }681 682 /// <summary>683 /// Constructs a ProviderNotFoundException.684 /// </summary>685 /// <param name="message">686 /// The message used by the exception.687 /// </param>688 /// <param name="innerException">689 /// The exception that caused the error.690 /// </param>691 public ProviderNotFoundException(string message,692 Exception innerException)693 : base(message, innerException)694 {695 }696 #endregion ctor697 }698 699 /// <summary>700 /// ProviderNameAmbiguousException occurs when more than one provider exists701 /// for a given name and the request did not contain the PSSnapin name qualifier.702 /// </summary>703 public class ProviderNameAmbiguousException : ProviderNotFoundException704 {705 #region ctor706 /// <summary>707 /// Constructs a ProviderNameAmbiguousException.708 /// </summary>709 /// <param name="providerName">710 /// The name of provider that was ambiguous.711 /// </param>712 /// <param name="errorIdAndResourceId">713 /// This string is the ErrorId passed to the ErrorRecord, and is also714 /// the resourceId used to look up the message template string in715 /// SessionStateStrings.txt.716 /// </param>717 /// <param name="resourceStr">718 /// This string is the message template string719 /// </param>720 /// <param name="possibleMatches">721 /// The provider information for the providers that match the specified722 /// name.723 /// </param>724 /// <param name="messageArgs">725 /// Additional arguments to build the message from.726 /// </param>727 internal ProviderNameAmbiguousException(728 string providerName,729 string errorIdAndResourceId,730 string resourceStr,731 Collection<ProviderInfo> possibleMatches,732 params object[] messageArgs)733 : base(734 providerName,735 SessionStateCategory.CmdletProvider,736 errorIdAndResourceId,737 resourceStr,738 messageArgs)739 {740 _possibleMatches = new ReadOnlyCollection<ProviderInfo>(possibleMatches);741 }742 743 /// <summary>744 /// Constructs a ProviderNameAmbiguousException.745 /// </summary>746 public ProviderNameAmbiguousException()747 : base()748 {749 }750 751 /// <summary>752 /// Constructs a ProviderNameAmbiguousException.753 /// </summary>754 /// <param name="message">755 /// The messaged used by the exception.756 /// </param>757 public ProviderNameAmbiguousException(string message)758 : base(message)759 {760 }761 762 /// <summary>763 /// Constructs a ProviderNameAmbiguousException.764 /// </summary>765 /// <param name="message">766 /// The message used by the exception.767 /// </param>768 /// <param name="innerException">769 /// The exception that caused the error.770 /// </param>771 public ProviderNameAmbiguousException(string message,772 Exception innerException)773 : base(message, innerException)774 {775 }776 #endregion ctor777 778 /// <summary>779 /// Constructs a ProviderNameAmbiguousException using serialized data.780 /// </summary>781 /// <param name="info">Serialization information.</param>782 /// <param name="context">Streaming context.</param>783 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]784 protected ProviderNameAmbiguousException(785 SerializationInfo info,786 StreamingContext context)787 {788 throw new NotSupportedException();789 }790 791 #region public properties792 793 /// <summary>794 /// Gets the information of the providers which might match the specified795 /// provider name.796 /// </summary>797 public ReadOnlyCollection<ProviderInfo> PossibleMatches798 {799 get800 {801 return _possibleMatches;802 }803 }804 805 private readonly ReadOnlyCollection<ProviderInfo> _possibleMatches;806 807 #endregion public properties808 }809 810 /// <summary>811 /// DriveNotFoundException occurs when no drive can be found812 /// with the specified name.813 /// </summary>814 public class DriveNotFoundException : SessionStateException815 {816 #region ctor817 /// <summary>818 /// Constructs a DriveNotFoundException.819 /// </summary>820 /// <param name="itemName">821 /// The name of the drive that could not be found.822 /// </param>823 /// <param name="errorIdAndResourceId">824 /// This string is the ErrorId passed to the ErrorRecord, and is also825 /// the resourceId used to look up the message template string in826 /// SessionStateStrings.txt.827 /// </param>828 /// <param name="resourceStr">829 /// This string is the message template string830 /// </param>831 internal DriveNotFoundException(832 string itemName,833 string errorIdAndResourceId,834 string resourceStr835 )836 : base(itemName, SessionStateCategory.Drive,837 errorIdAndResourceId, resourceStr, ErrorCategory.ObjectNotFound)838 {839 }840 841 /// <summary>842 /// Constructs a DriveNotFoundException.843 /// </summary>844 public DriveNotFoundException()845 : base()846 {847 }848 849 /// <summary>850 /// Constructs a DriveNotFoundException.851 /// </summary>852 /// <param name="message">853 /// The message that will be used by the exception.854 /// </param>855 public DriveNotFoundException(string message)856 : base(message)857 {858 }859 860 /// <summary>861 /// Constructs a DriveNotFoundException.862 /// </summary>863 /// <param name="message">864 /// The message that will be used by the exception.865 /// </param>866 /// <param name="innerException">867 /// The exception that caused the error.868 /// </param>869 public DriveNotFoundException(string message,870 Exception innerException)871 : base(message, innerException)872 {873 }874 #endregion ctor875 876 /// <summary>877 /// Constructs a DriveNotFoundException using serialized data.878 /// </summary>879 /// <param name="info">Serialization information.</param>880 /// <param name="context">Streaming context.</param>881 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]882 protected DriveNotFoundException(883 SerializationInfo info,884 StreamingContext context)885 {886 throw new NotSupportedException();887 }888 }889 890 /// <summary>891 /// ItemNotFoundException occurs when the path contained no wildcard characters892 /// and an item at that path could not be found.893 /// </summary>894 public class ItemNotFoundException : SessionStateException895 {896 #region ctor897 /// <summary>898 /// Constructs a ItemNotFoundException.899 /// </summary>900 /// <param name="path">901 /// The path that was not found.902 /// </param>903 /// <param name="errorIdAndResourceId">904 /// This string is the ErrorId passed to the ErrorRecord, and is also905 /// the resourceId used to look up the message template string in906 /// SessionStateStrings.txt.907 /// </param>908 /// <param name="resourceStr">909 /// This string is the ErrorId passed to the ErrorRecord, and is also910 /// the resourceId used to look up the message template string in911 /// SessionStateStrings.txt.912 /// </param>913 internal ItemNotFoundException(914 string path,915 string errorIdAndResourceId,916 string resourceStr917 )918 : base(path, SessionStateCategory.Drive,919 errorIdAndResourceId, resourceStr, ErrorCategory.ObjectNotFound)920 {921 }922 923 /// <summary>924 /// Constructs a ItemNotFoundException.925 /// </summary>926 public ItemNotFoundException()927 : base()928 {929 }930 931 /// <summary>932 /// Constructs a ItemNotFoundException.933 /// </summary>934 /// <param name="message">935 /// The message used by the exception.936 /// </param>937 public ItemNotFoundException(string message)938 : base(message)939 {940 }941 942 /// <summary>943 /// Constructs a ItemNotFoundException.944 /// </summary>945 /// <param name="message">946 /// The message used by the exception.947 /// </param>948 /// <param name="innerException">949 /// The exception that caused the error.950 /// </param>951 public ItemNotFoundException(string message,952 Exception innerException)953 : base(message, innerException)954 {955 }956 #endregion ctor957 958 /// <summary>959 /// Constructs a ItemNotFoundException using serialized data.960 /// </summary>961 /// <param name="info">Serialization information.</param>962 /// <param name="context">Streaming context.</param>963 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]964 protected ItemNotFoundException(965 SerializationInfo info,966 StreamingContext context)967 {968 throw new NotSupportedException();969 }970 }971}972 