Permalink
Browse files

Make sure to throw {badfun, Term} correctly

  • Loading branch information...
1 parent 04250f1 commit 599c6a15327fc2d357085d554536ff6fd344876d @krestenkrab krestenkrab committed Oct 6, 2013
Showing with 6 additions and 2 deletions.
  1. +5 −1 src/main/java/erjang/ERT.java
  2. +1 −1 src/main/java/erjang/m/erlang/ErlBif.java
@@ -130,6 +130,10 @@ public static ErlangError badarith(BigInteger o1, EObject o2) {
throw new ErlangError(AM_BADARITH, NIL.cons(o2).cons(o1));
}
+ public static ErlangError badfun(EObject o) {
+ throw new ErlangError(new ETuple2(am_badfun, o));
+ }
+
public static final EAtom TRUE = EAtom.intern("true");
public static final EAtom FALSE = EAtom.intern("false");
@@ -355,7 +359,7 @@ public static void test_fun(EObject orig, EFun fun) {
if ((orig.testFunction()) != null) {
throw new ErlangError(new ETuple2(am_badarity, new ETuple2(orig, NIL)));
} else {
- throw new ErlangError(am_badfun, orig);
+ throw badfun(orig);
}
}
}
@@ -113,7 +113,7 @@ static EObject apply(EProc proc, EObject fun, EObject args) throws Pausable {
ETuple t = fun.testTuple();
if (t == null) {
- throw ERT.badarg(fun,args);
+ throw ERT.badfun(fun);
}
ETuple2 t2 = ETuple2.cast(t);

0 comments on commit 599c6a1

Please sign in to comment.