question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Catching errors when using js_api

See original GitHub issue

Specification

  • pywebview version: 3.4
  • platform / version: Windows

Description

I am using a custom Api() class to communicate Javascript withPython. My problem is any error/exception won’t show in the Python terminal. I can see the python error in the Chromium console, but I’d like to catch it in the terminal also.

This is the code:

if __name__ == '__main__':

    api = Api()
    window = webview.create_window('Wear Indicator Tool',
                                   url="web/conexion.html",
                                   js_api=api,
                                   resizable=True,
                                   min_size=(1200, 800),
                                   )
    webview.start(debug=True)

I believe the issue has to do more with threading than with pywebview, but I’m unable to solve it.

Any help is greatly appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
r0x0rcommented, Dec 23, 2020

Yeah, this is a threading problem. You can wrap your threading code in try … except, display an exception and rethrow an exception if needed.

0reactions
github-actions[bot]commented, Mar 12, 2021

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fetch: reject promise and catch the error if status is not OK?
Fetch promises only reject with a TypeError when a network error occurs. Since 4xx and 5xx responses aren't network errors, there's nothing ...
Read more >
Error handling while using native fetch API in JavaScript
We will see, how to handle fetch API errors using promises and async await syntax in JavaScript.
Read more >
JSAPI capturing errors in application and making d...
For example, today I saw an error in the console (here Google Chrome's console) of "TypeError", with a message of "undefined is not...
Read more >
JavaScript Errors Try Catch Throw - W3Schools
JavaScript try and catch​​ The try statement allows you to define a block of code to be tested for errors while it is...
Read more >
A Comprehensive Guide To Error Handling In Node.js
The most common way for functions to deliver errors is by throwing them. When you throw an error, it becomes an exception and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found