File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,17 @@ typedef long long mp_longint_impl_t;
9494#define MICROPY_ENABLE_DOC_STRING (0)
9595#endif
9696
97+ // Exception messages are short static strings (TODO)
98+ #define MICROPY_ERROR_REPORTING_TERSE (1)
99+ // Exception messages provide basic error details
100+ #define MICROPY_ERROR_REPORTING_NORMAL (2)
101+ // Exception messages provide full info, e.g. object names
102+ #define MICROPY_ERROR_REPORTING_DETAILED (3)
103+
104+ #ifndef MICROPY_ERROR_REPORTING
105+ #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
106+ #endif
107+
97108// Float and complex implementation
98109#define MICROPY_FLOAT_IMPL_NONE (0)
99110#define MICROPY_FLOAT_IMPL_FLOAT (1)
Original file line number Diff line number Diff line change @@ -152,8 +152,18 @@ STATIC void dump_args(const mp_obj_t *a, int sz) {
152152#endif
153153
154154STATIC NORETURN void fun_pos_args_mismatch (mp_obj_fun_bc_t * f , uint expected , uint given ) {
155+ #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
156+ // Generic message, to be reused for other argument issues
157+ nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
158+ "argument num/types mismatch" ));
159+ #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
155160 nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
156161 "function takes %d positional arguments but %d were given" , expected , given ));
162+ #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
163+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
164+ "%s() takes %d positional arguments but %d were given" ,
165+ mp_obj_fun_get_name (f ), expected , given ));
166+ #endif
157167}
158168
159169// If it's possible to call a function without allocating new argument array,
Original file line number Diff line number Diff line change 1616#define MICROPY_USE_COMPUTED_GOTO (1)
1717#define MICROPY_MOD_SYS_STDFILES (1)
1818#define MICROPY_ENABLE_MOD_CMATH (1)
19+ // Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc.
20+ // names in exception messages (may require more RAM).
21+ #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
1922
2023extern const struct _mp_obj_module_t mp_module_time ;
2124extern const struct _mp_obj_module_t mp_module_socket ;
You can’t perform that action at this time.
0 commit comments