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 /// Defines the exception that is thrown if a native command fails.10 /// </summary>11 public class ApplicationFailedException : RuntimeException12 {13 #region private14 private const string errorIdString = "NativeCommandFailed";15 #endregion16 17 #region ctor18 19 #region Serialization20 /// <summary>21 /// Initializes a new instance of the ApplicationFailedException class and defines the serialization information,22 /// and streaming context.23 /// </summary>24 /// <param name="info">The serialization information to use when initializing this object.</param>25 /// <param name="context">The streaming context to use when initializing this object.</param>26 /// <returns>Constructed object.</returns>27 [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]28 protected ApplicationFailedException(SerializationInfo info,29 StreamingContext context)30 {31 throw new NotSupportedException();32 }33 #endregion Serialization34 35 /// <summary>36 /// Initializes a new instance of the class ApplicationFailedException.37 /// </summary>38 /// <returns>Constructed object.</returns>39 public ApplicationFailedException() : base()40 {41 base.SetErrorId(errorIdString);42 base.SetErrorCategory(ErrorCategory.ResourceUnavailable);43 }44 45 /// <summary>46 /// Initializes a new instance of the ApplicationFailedException class and defines the error message.47 /// </summary>48 /// <param name="message">The error message to use when initializing this object.</param>49 /// <returns>Constructed object.</returns>50 public ApplicationFailedException(string message) : base(message)51 {52 base.SetErrorId(errorIdString);53 base.SetErrorCategory(ErrorCategory.ResourceUnavailable);54 }55 56 /// <summary>57 /// Initializes a new instance of the ApplicationFailedException class and defines the error message and58 /// errorID.59 /// </summary>60 /// <param name="message">The error message to use when initializing this object.</param>61 /// <param name="errorId">The errorId to use when initializing this object.</param>62 /// <returns>Constructed object.</returns>63 internal ApplicationFailedException(string message, string errorId) : base(message)64 {65 base.SetErrorId(errorId);66 base.SetErrorCategory(ErrorCategory.ResourceUnavailable);67 }68 69 /// <summary>70 /// Initializes a new instance of the ApplicationFailedException class and defines the error message,71 /// error ID and inner exception.72 /// </summary>73 /// <param name="message">The error message to use when initializing this object.</param>74 /// <param name="errorId">The errorId to use when initializing this object.</param>75 /// <param name="innerException">The inner exception to use when initializing this object.</param>76 /// <returns>Constructed object.</returns>77 internal ApplicationFailedException(string message, string errorId, Exception innerException)78 : base(message, innerException)79 {80 base.SetErrorId(errorId);81 base.SetErrorCategory(ErrorCategory.ResourceUnavailable);82 }83 84 /// <summary>85 /// Initializes a new instance of the ApplicationFailedException class and defines the error message and86 /// inner exception.87 /// </summary>88 /// <param name="message">The error message to use when initializing this object.</param>89 /// <param name="innerException">The inner exception to use when initializing this object.</param>90 /// <returns>Constructed object.</returns>91 public ApplicationFailedException(string message,92 Exception innerException)93 : base(message, innerException)94 {95 base.SetErrorId(errorIdString);96 base.SetErrorCategory(ErrorCategory.ResourceUnavailable);97 }98 #endregion ctor99 }100}101 