Skip to content

Commit

Permalink
Make sure to throw {badfun, Term} correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
krestenkrab committed Oct 6, 2013
1 parent 04250f1 commit 599c6a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/java/erjang/ERT.java
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/erjang/m/erlang/ErlBif.java
Expand Up @@ -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);
Expand Down

0 comments on commit 599c6a1

Please sign in to comment.