39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
namespace EnotaryoPH.Web.Common.Exceptions
|
|
{
|
|
public class NoDataException : Exception
|
|
{
|
|
public NoDataException(string typeName, object id) : base($"No data found for {typeName} with id = '{id}'.")
|
|
{
|
|
TypeName = typeName;
|
|
ID = id;
|
|
Key = string.Empty;
|
|
}
|
|
|
|
public NoDataException(string typeName, object id, string key) : base($"No data found for {typeName} with {key} = '{id}'.")
|
|
{
|
|
TypeName = typeName;
|
|
ID = id;
|
|
Key = key;
|
|
}
|
|
|
|
public static void ThrowIfNull(object data, string typeName, object id)
|
|
{
|
|
if (data == null)
|
|
{
|
|
throw new NoDataException(typeName, id);
|
|
}
|
|
}
|
|
|
|
public static void ThrowIfNull(object data, string typeName, object id, string key)
|
|
{
|
|
if (data == null)
|
|
{
|
|
throw new NoDataException(typeName, id, key);
|
|
}
|
|
}
|
|
|
|
public object ID { get; private set; }
|
|
public string Key { get; private set; }
|
|
public string TypeName { get; private set; }
|
|
}
|
|
} |