chore: Added Initial Engine Code
This commit is contained in:
21
Engine.Core/Exceptions/NotAssignedException.cs
Normal file
21
Engine.Core/Exceptions/NotAssignedException.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
|
||||
namespace Syntriax.Engine.Core.Exceptions;
|
||||
|
||||
public class NotAssignedException : Exception
|
||||
{
|
||||
public NotAssignedException() : base("The object has not been assigned.") { }
|
||||
public NotAssignedException(string? message) : base(message) { }
|
||||
|
||||
public static NotAssignedException From<T1, T2>(T1 to, T2? value) where T1 : IAssignable
|
||||
=> new NotAssignedException($"{typeof(T2).Name} has not been assigned to {typeof(T1).Name}");
|
||||
|
||||
public static void Check<T1, T2>(T1 to, T2? value) where T1 : IAssignable
|
||||
{
|
||||
if (value is not null)
|
||||
return;
|
||||
|
||||
throw From(to, value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user