Skip to content

Commit e7bad70

Browse files
exceptions handlers
Co-Authored-By: VLTA of @TheFlightSims <176574466+anhvlt-2k6@users.noreply.github.com>
1 parent 59d7d0c commit e7bad70

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

WMIMethods/CommonException.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
3+
/*
4+
* The default WMI method class includes:
5+
* 1. CriticalException.cs - A custom exception class for critical WMI errors
6+
* 2. CommonException.cs - A custom exception class for common WMI errors
7+
* 3. MachineMethods.cs - A base class for WMI operations on local and remote machines
8+
*/
9+
namespace GetWMIBasic.WMIMethods
10+
{
11+
/*
12+
* Common Exception class
13+
* It is used to test common exceptions in WMI operations
14+
*/
15+
public class CommonException : SystemException
16+
{
17+
// Default constructor - No custom message (use default message)
18+
public CommonException()
19+
{
20+
// Throw a new exception with a default message
21+
throw new Exception("This is a custom exception for WMI-related errors.");
22+
}
23+
24+
// Default constructor - with custom message
25+
public CommonException(string message) : base(message)
26+
{
27+
// Throw a new exception with custom message
28+
throw new Exception(message);
29+
}
30+
}
31+
}

WMIMethods/CriticalException.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
3+
/*
4+
* The default WMI method class includes:
5+
* 1. CriticalException.cs - A custom exception class for critical WMI errors
6+
* 2. CommonException.cs - A custom exception class for common WMI errors
7+
* 3. MachineMethods.cs - A base class for WMI operations on local and remote machines
8+
*/
9+
namespace GetWMIBasic.WMIMethods
10+
{
11+
/*
12+
* Critical Exception class
13+
* It is used to test critical exceptions in WMI operations
14+
*/
15+
public class CriticalException : SystemException
16+
{
17+
// Default constructor - No custom message (use default message)
18+
public CriticalException()
19+
{
20+
// Throw a new exception with a default message
21+
throw new Exception("A critical exception has occurred in the WMI operations.");
22+
}
23+
24+
// Default constructor - with custom message
25+
public CriticalException(string message) : base(message)
26+
{
27+
// Throw a new exception with custom message
28+
throw new Exception(message);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)