-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathObjectNotFoundException.cs
More file actions
42 lines (34 loc) · 1.19 KB
/
ObjectNotFoundException.cs
File metadata and controls
42 lines (34 loc) · 1.19 KB
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
34
35
36
37
38
39
40
41
42
using System;
namespace OlegHcp.SingleScripts
{
public class ObjectNotFoundException : SystemException
{
private Type _objectType;
public Type ObjectType => _objectType;
public override string Message
{
get
{
if (_objectType is null)
return base.Message;
return base.Message + Environment.NewLine + GetValueMessage(_objectType);
}
}
public ObjectNotFoundException() : base(GetMessage()) { }
public ObjectNotFoundException(string message) : base(message) { }
public ObjectNotFoundException(string message, Exception innerException) : base(message, innerException) { }
public ObjectNotFoundException(Exception innerException) : base(GetMessage(), innerException) { }
public ObjectNotFoundException(Type type) : this()
{
_objectType = type;
}
private static string GetMessage()
{
return $"There is no any instance of object.";
}
private static string GetValueMessage(Type type)
{
return $"Object type is {type.FullName}.";
}
}
}