Fine tuning of error_handling debug tools (#1142)

This commit is contained in:
Hood Chatham 2021-01-15 18:40:01 -08:00 committed by GitHub
parent 4c5c30779f
commit 603d223b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -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)
{

View File

@ -7,6 +7,7 @@
#include <emscripten.h>
typedef int errcode;
#include "hiwire.h"
int
error_handling_init();
@ -14,6 +15,11 @@ 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
@ -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; \
} \
@ -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; \
} \