summaryrefslogtreecommitdiffstatshomepage
path: root/py/objexcept.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-19 11:48:48 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-19 11:48:48 +0000
commitcbd2f7482c8bf457cc17da763859dbba6e03e2a2 (patch)
tree8d6badc4197fe0d5763d381dd97586176db9fbae /py/objexcept.c
parente02b2d43912d13d216936786e4b7a33918877418 (diff)
downloadmicropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.tar.gz
micropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.zip
py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name. Also tidy up some debug printing functions and provide a global flag to enable/disable them.
Diffstat (limited to 'py/objexcept.c')
-rw-r--r--py/objexcept.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/py/objexcept.c b/py/objexcept.c
index 7f87478a89..326d320d52 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -19,6 +19,7 @@ typedef struct mp_obj_exception_t {
mp_obj_base_t base;
qstr source_file;
machine_uint_t source_line;
+ qstr source_block;
qstr id;
qstr msg;
mp_obj_tuple_t args;
@@ -114,7 +115,7 @@ qstr mp_obj_exception_get_type(mp_obj_t self_in) {
return self->id;
}
-void mp_obj_exception_set_source_info(mp_obj_t self_in, qstr file, machine_uint_t line) {
+void mp_obj_exception_set_source_info(mp_obj_t self_in, qstr file, machine_uint_t line, qstr block) {
assert(MP_OBJ_IS_TYPE(self_in, &exception_type));
mp_obj_exception_t *self = self_in;
// TODO make a list of file/line pairs for the traceback
@@ -125,11 +126,15 @@ void mp_obj_exception_set_source_info(mp_obj_t self_in, qstr file, machine_uint_
if (line != 0 && self->source_line == 0) {
self->source_line = line;
}
+ if (block != 0 && self->source_block == 0) {
+ self->source_block = block;
+ }
}
-void mp_obj_exception_get_source_info(mp_obj_t self_in, qstr *file, machine_uint_t *line) {
+void mp_obj_exception_get_source_info(mp_obj_t self_in, qstr *file, machine_uint_t *line, qstr *block) {
assert(MP_OBJ_IS_TYPE(self_in, &exception_type));
mp_obj_exception_t *self = self_in;
*file = self->source_file;
*line = self->source_line;
+ *block = self->source_block;
}