summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
authorDamien <damien.p.george@gmail.com>2013-10-15 22:25:17 +0100
committerDamien <damien.p.george@gmail.com>2013-10-15 22:25:17 +0100
commitce89a21ea49e51274d016d9601c462312664271e (patch)
treed9ad69657b6ad313c988ce201a42e97d5cd38a39 /unix/main.c
parent5dd455d06dd3cdda7daf496822776b0c8319f02b (diff)
downloadmicropython-ce89a21ea49e51274d016d9601c462312664271e.tar.gz
micropython-ce89a21ea49e51274d016d9601c462312664271e.zip
Implement basic exception framework, and simple for loop.
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/unix/main.c b/unix/main.c
index eb120da019..8ceaf42646 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
+#include "nlr.h"
#include "misc.h"
#include "mpyconfig.h"
#include "lexer.h"
@@ -47,10 +48,19 @@ int main(int argc, char **argv) {
// execute it
py_obj_t module_fun = rt_make_function_from_id(1);
if (module_fun != py_const_none) {
- py_obj_t ret = rt_call_function_0(module_fun);
- printf("done! got: ");
- py_obj_print(ret);
- printf("\n");
+ nlr_buf_t nlr;
+ if (nlr_push(&nlr) == 0) {
+ py_obj_t ret = rt_call_function_0(module_fun);
+ printf("done! got: ");
+ py_obj_print(ret);
+ printf("\n");
+ nlr_pop();
+ } else {
+ // uncaught exception
+ printf("exception: ");
+ py_obj_print((py_obj_t)nlr.ret_val);
+ printf("\n");
+ }
}
}
#endif