Permalink
Browse files

Better (albeit not perfect) exception for badarity invocation of anon…

…ymous function.
  • Loading branch information...
1 parent 1f07d38 commit 2a0da3fee05f2844b817983ded2ba1729f4b9a45 @krestenkrab krestenkrab committed Feb 14, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/main/java/erjang/ERT.java
View
10 src/main/java/erjang/ERT.java
@@ -342,8 +342,13 @@ public static String describe_exception(Throwable e) {
}
public static void test_fun(EObject orig, EFun fun) {
- if (fun == null)
- throw new ErlangError(am_badfun, orig);
+ if (fun == null) {
+ if ((orig.testFunction()) != null) {
+ throw new ErlangError(new ETuple2(am_badarity, new ETuple2(orig, NIL)));
+ } else {
+ throw new ErlangError(am_badfun, orig);
+ }
+ }
}
static EInteger max_send_time = ERT.box(4294967295L);
@@ -779,6 +784,7 @@ public static EObject try_case_end(EObject val) {
public static EAtom am_attributes = EAtom.intern("attributes");
public static EAtom am_exports = EAtom.intern("exports");
public static EAtom am_badfun = EAtom.intern("badfun");
+ public static EAtom am_badarity = EAtom.intern("badarity");
public static EAtom am_name = EAtom.intern("name");
public static EAtom am_arity = EAtom.intern("arity");

0 comments on commit 2a0da3f

Please sign in to comment.