Improve error description for evaluation failure.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <param name="exp">The expression to evaluate.</param>
|
/// <param name="exp">The expression to evaluate.</param>
|
||||||
/// <returns>Whether the evaluaton succeeded.</returns>
|
/// <returns>Whether the evaluaton succeeded.</returns>
|
||||||
public bool Evaluate(PdtOperator target, PdtExpression exp) {
|
public bool Evaluate(PdtOperator target, PdtExpression exp) {
|
||||||
|
try {
|
||||||
var prevFrameCount = _framecount;
|
var prevFrameCount = _framecount;
|
||||||
_revokepttconst = false;
|
_revokepttconst = false;
|
||||||
for (var ip = exp.Instructions.First; ip != null; ip = ip.Next)
|
for (var ip = exp.Instructions.First; ip != null; ip = ip.Next)
|
||||||
@@ -35,6 +36,10 @@ namespace Cryville.Common.Pdt {
|
|||||||
for (var i = prevFrameCount; i < _framecount; i++) DiscardStack();
|
for (var i = prevFrameCount; i < _framecount; i++) DiscardStack();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw new EvaluationFailureException(exp, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optimizes an expression by merging its instructions.
|
/// Optimizes an expression by merging its instructions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -257,5 +262,16 @@ namespace Cryville.Common.Pdt {
|
|||||||
public EvaluationFailureException(string message, Exception innerException) : base(message, innerException) { }
|
public EvaluationFailureException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected EvaluationFailureException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
protected EvaluationFailureException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="EvaluationFailureException" /> class with the failing expression.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="exp">The failing expression.</param>
|
||||||
|
public EvaluationFailureException(PdtExpression exp) : base("Evaluation failed for the expression: " + exp.ToString()) { }
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="EvaluationFailureException" /> class with the failing expression and the inner exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="exp">The failing expression.</param>
|
||||||
|
/// <param name="innerException">The inner exception.</param>
|
||||||
|
public EvaluationFailureException(PdtExpression exp, Exception innerException) : base("Evaluation failed for the expression: " + exp.ToString(), innerException) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user