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.

No error bubbling?

See original GitHub issue

Hi, if an exception is thrown during an interactive action, such as a callback invoked by Canvas.on_mouse_down, there seems to be no way of knowing this.

e.g.:

from ipycanvas import Canvas

def callback(*args):
    raise ValueError("Invisible")

c = Canvas(size=(500, 500))
c.on_mouse_down(callback)
c

by contrast, errors in ipywidgets.Button calls are reported in the jupyter lab log:

from ipywidgets import Button
b = Button(description='Hi')

def callback(*args):
    raise ValueError("Invisible")

b.on_click(callback)
b

image

Is it possible to match this behaviour?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kenseehartcommented, May 20, 2020

Here’s my workaround:

import traceback

class MyUI:
    def __init__(self, canvas, model):
        self.canvas = canvas
        self.model = model
        canvas.on_mouse_down(self.mouse_down)

    def mouse_down(self, x, y):
        try:
            do_some_stuff()
        except:
            self.print_traceback()
            
    def print_traceback(self):
        self.canvas.fill_style = '#ff8888'
        self.canvas.fill_rect(10, 10, 300, 300)
        self.canvas.fill_style = '#000000'
        s = traceback.format_exc()
        for i, si in enumerate(s.split('\n')):
            canvas.fill_text(si, 20, 30+15*i)    

Works great. Now my code is debugable.

1reaction
janfreybergcommented, May 20, 2020

that’s a really neat workaround, thanks @kenseehart

Read more comments on GitHub >

github_iconTop Results From Across the Web

what's meant by bubbling? (Example) | Treehouse Community
If it isn't handled immediately, it jumps up the call stack, until it finds code to handle it (a try/catch for the appropriate...
Read more >
Exception Bubbling in C# - TechNet Articles
An error can occur at almost any statement. Checking for all these errors becomes unbearably complex. Exception handling separates this logic.
Read more >
ES6 Promise Errors not bubbling up as expected
Now I get what I expect, the error is not uncaught. But this seems counter to the whole idea that errors bubble up,...
Read more >
How to avoid a bubbling error on the LSAT
A bubbling error is when one or more answers are incorrectly filled in for an answer key. This can happen if the test...
Read more >
Put action is bubbling errors · Issue #1844 - GitHub
The Expected results. As I understand, in this case, error should not bubble up to saga. Environment information. redux-saga version - 1.0.
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