diff --git a/internal/interpreter/interpreter_error.go b/internal/interpreter/interpreter_error.go index 1d5bc415..672b8558 100644 --- a/internal/interpreter/interpreter_error.go +++ b/internal/interpreter/interpreter_error.go @@ -27,6 +27,11 @@ func (e MissingFundsErr) Error() string { return fmt.Sprintf("Not enough funds. Needed [%s %s] (only [%s %s] available)", e.Asset, e.Needed.String(), e.Asset, e.Available.String()) } +func (e MissingFundsErr) Is(target error) bool { + _, ok := target.(MissingFundsErr) + return ok +} + type InvalidMonetaryLiteral struct { parser.Range Source string diff --git a/numscript.go b/numscript.go index 98df032a..35bc10e0 100644 --- a/numscript.go +++ b/numscript.go @@ -72,6 +72,7 @@ type ( Value = interpreter.Value InterpreterError = interpreter.InterpreterError + MissingFundsErr = interpreter.MissingFundsErr ) func (p ParseResult) Run(ctx context.Context, vars VariablesMap, store Store) (ExecutionResult, InterpreterError) {