Dependency
- Now throws a `DependencyException` on erronenous calls - Added `DependencyException` exception class and `DependencyError` enum
This commit is contained in:
parent
68e1a25c9a
commit
57ebd443b0
|
@ -12,7 +12,7 @@ import compiler.typecheck.exceptions;
|
|||
import compiler.typecheck.core;
|
||||
import compiler.symbols.typing.core;
|
||||
import compiler.symbols.typing.builtins;
|
||||
|
||||
import compiler.typecheck.dependency.exceptions : DependencyException, DependencyError;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -246,8 +246,7 @@ public class DNode
|
|||
{
|
||||
if(hasLinearized)
|
||||
{
|
||||
// TODO: make this a DependencyException type
|
||||
throw new Exception("Cannot re-perform linearization");
|
||||
throw new DependencyException(DependencyError.ALREADY_LINEARIZED);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -267,8 +266,7 @@ public class DNode
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO: make this a DependencyException type
|
||||
throw new Exception("Cannot call getLinearizedNodes() unless you have called `performLinearization()`");
|
||||
throw new DependencyException(DependencyError.NOT_YET_LINEARIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,8 +278,7 @@ public class DNode
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO: make this a DependencyException type
|
||||
throw new Exception("Cannot call getTree() unless you have called `performLinearization()`");
|
||||
throw new DependencyException(DependencyError.NOT_YET_LINEARIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
module compiler.typecheck.dependency.exceptions;
|
||||
|
||||
import misc.exceptions : TError;
|
||||
import std.conv : to;
|
||||
|
||||
// FIXME: Extend TError rather than Exception
|
||||
public enum DependencyError
|
||||
{
|
||||
NOT_YET_LINEARIZED,
|
||||
ALREADY_LINEARIZED,
|
||||
}
|
||||
|
||||
public final class DependencyException : TError
|
||||
{
|
||||
private DependencyError errTye;
|
||||
|
||||
this(DependencyError errTye, string occuring = __FUNCTION__)
|
||||
{
|
||||
super("DependencyException("~occuring~"): We got a "~to!(string)(errTye));
|
||||
this.errTye = errTye;
|
||||
}
|
||||
|
||||
public DependencyError getErrorType()
|
||||
{
|
||||
return errTye;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue