Created
January 29, 2018 23:40
-
-
Save luisdeol/ecef3bb57b7d2975abb0eaaeca9eb6ac to your computer and use it in GitHub Desktop.
Creating a Custom Exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Runtime.Serialization; | |
| namespace implement_exception_handling | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Console.ReadKey(); | |
| } | |
| } | |
| [Serializable] | |
| public class NotSoGreatException : Exception | |
| { | |
| public string NotSoGreatName { get; set; } | |
| public NotSoGreatException(string boringName) | |
| { | |
| NotSoGreatName = boringName; | |
| HelpLink = "https://medium.com/@luisdeolme/"; | |
| } | |
| public NotSoGreatException(string boringName, string message) | |
| : base(message) | |
| { | |
| NotSoGreatName = boringName; | |
| HelpLink = "https://medium.com/@luisdeolme/"; | |
| } | |
| public NotSoGreatException(string boringName, string message, Exception innerException) | |
| : base(message, innerException) | |
| { | |
| NotSoGreatName = boringName; | |
| HelpLink = "https://medium.com/@luisdeolme/"; | |
| } | |
| public NotSoGreatException(SerializationInfo serializationInfo, StreamingContext streamingContext) | |
| { | |
| NotSoGreatName = (string) serializationInfo.GetValue("NotSoGreatName", typeof(string)); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment