Skip to content

Commit

Permalink
Fine tuning of error_handling debug tools (pyodide#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hood Chatham authored Jan 16, 2021
1 parent 4c5c307 commit 603d223
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/core/error_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ EM_JS_NUM(errcode, log_error, (char* msg), {
console.error(jsmsg);
});

// Right now this is dead code (probably), please don't remove it.
// Intended for debugging purposes.
EM_JS_NUM(errcode, log_error_obj, (JsRef obj), {
console.error(Module.hiwire.get_value(obj));
});

void
PyodideErr_SetJsError(JsRef err)
{
Expand Down
10 changes: 8 additions & 2 deletions src/core/error_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
#include <emscripten.h>

typedef int errcode;
#include "hiwire.h"

int
error_handling_init();

errcode
log_error(char* msg);

// Right now this is dead code (probably), please don't remove it.
// Intended for debugging purposes.
errcode
log_error_obj(JsRef obj);

/** EM_JS Wrappers
* Wrap EM_JS so that it produces functions that follow the Python return
* conventions. We catch javascript errors and proxy them and use
Expand Down Expand Up @@ -59,7 +65,7 @@ log_error(char* msg);
try /* intentionally no braces, body already has them */ \
body /* <== body of func */ \
catch (e) { \
LOG_EM_JS_ERROR(func_name, err); \
LOG_EM_JS_ERROR(func_name, e); \
Module.handle_js_error(e); \
return 0; \
} \
Expand All @@ -74,7 +80,7 @@ log_error(char* msg);
try /* intentionally no braces, body already has them */ \
body /* <== body of func */ \
catch (e) { \
LOG_EM_JS_ERROR(func_name, err); \
LOG_EM_JS_ERROR(func_name, e); \
Module.handle_js_error(e); \
return -1; \
} \
Expand Down

0 comments on commit 603d223

Please sign in to comment.