ApplicationException.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. /*=============================================================================
  5. **
  6. **
  7. **
  8. ** Purpose: The base class for all "less serious" exceptions that must be
  9. ** declared or caught.
  10. **
  11. **
  12. =============================================================================*/
  13. using System.Runtime.Serialization;
  14. namespace System
  15. {
  16. // The ApplicationException is the base class for nonfatal,
  17. // application errors that occur. These exceptions are generated
  18. // (i.e., thrown) by an application, not the Runtime. Applications that need
  19. // to create their own exceptions do so by extending this class.
  20. // ApplicationException extends but adds no new functionality to
  21. // RecoverableException.
  22. [Serializable]
  23. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  24. public class ApplicationException : Exception
  25. {
  26. // Creates a new ApplicationException with its message string set to
  27. // the empty string, its HRESULT set to COR_E_APPLICATION,
  28. // and its ExceptionInfo reference set to null.
  29. public ApplicationException()
  30. : base(SR.Arg_ApplicationException)
  31. {
  32. HResult = HResults.COR_E_APPLICATION;
  33. }
  34. // Creates a new ApplicationException with its message string set to
  35. // message, its HRESULT set to COR_E_APPLICATION,
  36. // and its ExceptionInfo reference set to null.
  37. //
  38. public ApplicationException(string message)
  39. : base(message)
  40. {
  41. HResult = HResults.COR_E_APPLICATION;
  42. }
  43. public ApplicationException(string message, Exception innerException)
  44. : base(message, innerException)
  45. {
  46. HResult = HResults.COR_E_APPLICATION;
  47. }
  48. protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context)
  49. {
  50. }
  51. }
  52. }