How to catch "Javascript error"

26 views
Skip to first unread message

Yalon

unread,
Sep 17, 2023, 10:54:20 AM9/17/23
to brython
How to catch "Javascript error" in brython?

Thank you

Yalon

unread,
Sep 18, 2023, 3:37:06 AM9/18/23
to brython
I'm creating a javascript error on purpose - The "Javascript error" I'm getting, is plotted to the console by brython :
Javascript error
 Error: Javascript error

without any line number. How can I capture this message ?

Pierre Quentel

unread,
Sep 19, 2023, 3:12:10 AM9/19/23
to brython
Le lundi 18 septembre 2023 à 09:37:06 UTC+2, Yalon a écrit :
I'm creating a javascript error on purpose - The "Javascript error" I'm getting, is plotted to the console by brython :
Javascript error
 Error: Javascript error

without any line number. How can I capture this message ?


This is a very good question, thanks ! I have implemented the ability to catch such errors, as instances of a built-in class JavascriptError, in commit 1ea5ad3 today. 

With the latest development version you should be able to catch such errors with the usual syntax:

try:
    window.js_error_func()
except JavascriptError as exc:
    print('Javascript error', exc)

brython

unread,
Sep 19, 2023, 4:04:41 AM9/19/23
to brython
Thank you Pierre !
Show I download it directly from github ? When it will be availabe in the next release ? (https://github.com/brython-dev/brython/releases)

Pierre Quentel

unread,
Sep 20, 2023, 2:06:10 AM9/20/23
to brython
Le mardi 19 septembre 2023 à 10:04:41 UTC+2, Yalon a écrit :
Thank you Pierre !
Show I download it directly from github ? When it will be availabe in the next release ? (https://github.com/brython-dev/brython/releases)

If you are familiar with Git you can clone the repository and use the current development version.

Alternatively you can use it by including these scripts in the page:

<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython.js" crossorigin="anonymous"> </script>
<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython_stdlib.js" crossorigin="anonymous"> </script> 

The next version should be out before the end of this month but I can't be sure, there are many open issues at the moment.

Elon Keret

unread,
Sep 20, 2023, 2:54:36 AM9/20/23
to bry...@googlegroups.com
Thank you 

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/2f9b6efd-1ce5-47ca-83f6-c11ee18d584en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages