| 1589 | } |
| 1590 | |
| 1591 | GErrorResult<> GjsContextPrivate::register_module(const char* identifier, |
| 1592 | const char* uri) { |
| 1593 | Gjs::AutoMainRealm ar{this}; |
| 1594 | |
| 1595 | if (gjs_module_load(m_cx, identifier, uri)) |
| 1596 | return Ok{}; |
| 1597 | |
| 1598 | const char* msg = "unknown"; |
| 1599 | JS::ExceptionStack exn_stack(m_cx); |
| 1600 | JS::ErrorReportBuilder builder(m_cx); |
| 1601 | if (JS::StealPendingExceptionStack(m_cx, &exn_stack) && |
| 1602 | builder.init(m_cx, exn_stack, |
| 1603 | JS::ErrorReportBuilder::WithSideEffects)) { |
| 1604 | msg = builder.toStringResult().c_str(); |
| 1605 | } else { |
| 1606 | JS_ClearPendingException(m_cx); |
| 1607 | } |
| 1608 | |
| 1609 | Gjs::AutoError error; |
| 1610 | g_set_error(error.out(), GJS_ERROR, GJS_ERROR_FAILED, |
| 1611 | "Failed to parse module '%s': %s", identifier, |
| 1612 | msg ? msg : "unknown"); |
| 1613 | |
| 1614 | return Err(error.release()); |
| 1615 | } |
| 1616 | |
| 1617 | bool gjs_context_eval_file(GjsContext* self, const char* filename, |
| 1618 | int* exit_status_p, GError** error) { |
no test coverage detected