summaryrefslogtreecommitdiff
path: root/py/objfun.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-01 01:35:38 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-01 01:50:35 +0300
commit1f85d6255d6929edbcfc087e4e07c2fde39c3632 (patch)
tree218a841eb937c068cdace5710e408309c898cc7e /py/objfun.c
parent68551a842892bd03e82176c0de3b751779a95a0f (diff)
py: Add tentative scheme for error messages configuration.
Diffstat (limited to 'py/objfun.c')
-rw-r--r--py/objfun.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/py/objfun.c b/py/objfun.c
index 1c3208aca..94f6d26d7 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -152,8 +152,18 @@ STATIC void dump_args(const mp_obj_t *a, int sz) {
#endif
STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, uint expected, uint given) {
+#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
+ // Generic message, to be reused for other argument issues
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
+ "argument num/types mismatch"));
+#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"function takes %d positional arguments but %d were given", expected, given));
+#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
+ "%s() takes %d positional arguments but %d were given",
+ mp_obj_fun_get_name(f), expected, given));
+#endif
}
// If it's possible to call a function without allocating new argument array,