custom exceptions, methods to create modules and states of specific type from generic ones

This commit is contained in:
2022-11-20 22:17:32 +01:00
parent 8ee43d6823
commit b0df3f303a
9 changed files with 92 additions and 54 deletions

View File

@@ -49,8 +49,8 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
{
public bool IsSome() => false;
public bool IsNone() => true;
public T Expect(string message) => throw new Exception(message);
public T Unwrap() => throw new Exception("Tried to unwrap None.");
public T Expect(string message) => throw new OptionException(message);
public T Unwrap() => throw new OptionException("Tried to unwrap None.");
public T UnwrapOr(T def) => def;
public T UnwrapOrElse(Func<T> f) => f();
public IOption<T> And(IOption<T> other) => this;