-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomException.cs
33 lines (28 loc) · 1.15 KB
/
CustomException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KinoProject
{
// Class CustomException is responsible for delivering a custom message for a
// corresponding exception. The exceptions occur during the process of input data.
class CustomException : Exception
{
// Constructor with Parameters:
// When creating a new CustomException, it initiates with the following values:
// A string parameter that takes a custom message in case of a throw new exception.
// The specific parameter of the method, is passed in the base class Exception.
public CustomException(string message) : base(message)
{
}
// Prints messages according with the corresponding exceptions.
public static void CheckExceptions(Exception ex)
{
if (ex.GetType().ToString().Equals("System.FormatException") || ex.GetType().ToString().Equals("System.OverflowException"))
{
Console.WriteLine("Only positive integer numbers are allowed !");
}
}
}
}