Skip to content

Commit

Permalink
[JVM] Improve some error messages
Browse files Browse the repository at this point in the history
In the presence of named arguments the error could happen to be (e.g.):
'Wrong number of arguments passed; expected 1..1, but got 1'.
  • Loading branch information
usev6 committed Aug 31, 2019
1 parent 726917e commit 079fd82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/ArgsExpectation.java
Expand Up @@ -28,7 +28,8 @@ public static void invokeByExpectation(ThreadContext tc, CodeRef cr,
if (csd.argFlags.length != 0)
ExceptionHandling.dieInternal(tc,
"Wrong number of arguments passed; expected 0..0, but got " +
csd.numPositionals);
csd.argFlags.length +
" (" + csd.numPositionals + " of those positional)");
}
cr.staticInfo.mh.invokeExact(tc, cr, csd);
break;
Expand Down Expand Up @@ -63,13 +64,15 @@ public static void invokeByExpectation(ThreadContext tc, CodeRef cr,
default:
ExceptionHandling.dieInternal(tc,
"Wrong number of arguments passed; expected 1..1, but got " +
csd.numPositionals);
csd.argFlags.length +
" (" + csd.numPositionals + " of those positional)");
}
}
else {
ExceptionHandling.dieInternal(tc,
"Wrong number of arguments passed; expected 1..1, but got " +
csd.numPositionals);
csd.argFlags.length +
" (" + csd.numPositionals + " of those positional)");
}
}
break;
Expand Down Expand Up @@ -105,7 +108,8 @@ public static void invokeByExpectation(ThreadContext tc, CodeRef cr,
default:
ExceptionHandling.dieInternal(tc,
"Wrong number of arguments passed; expected 2..2, but got " +
csd.numPositionals);
csd.argFlags.length +
" (" + csd.numPositionals + " of those positional)");
}
switch (csd.argFlags[1]) {
case CallSiteDescriptor.ARG_OBJ:
Expand All @@ -123,14 +127,16 @@ public static void invokeByExpectation(ThreadContext tc, CodeRef cr,
default:
ExceptionHandling.dieInternal(tc,
"Wrong number of arguments passed; expected 2..2, but got " +
csd.numPositionals);
csd.argFlags.length +
" (" + csd.numPositionals + " of those positional)");
}
cr.staticInfo.mh.invokeExact(tc, cr, csd, arg1, arg2);
}
else {
ExceptionHandling.dieInternal(tc,
"Wrong number of arguments passed; expected 2..2, but got " +
csd.numPositionals);
csd.argFlags.length +
" (" + csd.numPositionals + " of those positional)");
}
}
break;
Expand Down
Expand Up @@ -87,7 +87,7 @@ public CallSiteDescriptor(byte[] flags, String[] names) {
hasFlattening = true;
break;
default:
new RuntimeException("Unhandld argument flag: " + af);
new RuntimeException("Unhandled argument flag: " + af);
}
}
}
Expand Down

0 comments on commit 079fd82

Please sign in to comment.