This repository was archived by the owner on Jun 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 88def py_random ():
99 return random .random ()
1010
11+ @eel .expose
12+ def py_exception (error ):
13+ if error :
14+ raise ValueError ("Test" )
15+ else :
16+ return "No Error"
17+
1118def print_num (n ):
1219 print ('Got this from Javascript:' , n )
1320
Original file line number Diff line number Diff line change 2020
2121 // Do the same with an inline callback
2222 eel . py_random ( ) ( n => console . log ( 'Got this from Python: ' + n ) ) ;
23-
23+
24+ // show usage with promises
25+ // show no error
26+ eel . py_exception ( false ) ( ) . then ( ( result ) => {
27+ // this will execute since we said no error
28+ console . log ( "No Error" )
29+ } ) . catch ( ( result ) => {
30+ console . log ( "This won't be seen if no error" )
31+ }
32+ ) ;
33+ // show if an error occurrs
34+ eel . py_exception ( true ) ( ) . then ( ( result ) => {
35+ // this will not execute
36+ console . log ( "No Error" )
37+ } ) . catch ( ( result ) => {
38+ console . log ( "This is the repr(e) for an exception " + result . errorText ) ;
39+ console . log ( "This is the full traceback:\n" + result . errorTraceback ) ;
40+ }
41+ )
2442 </ script >
2543 </ head >
2644
You can’t perform that action at this time.
0 commit comments