[An internal error has occurred] How to debug?

I’ve been getting a lot of [An internal error has occurred] errors. My guess is that this happens when I use translated javascript with “from anvil.js.window import some_js_library” and an error occurs.
The confusing thing is that the error is in my python code, not in the translated JS code. Whenever the translated JS code handles some event which calls my python code which contains an error I get the [An internal error has occurred] instead of the more appropriate and more informative python error code.

How do you go about debugging this error?

Have you checked out the end of the docs in accessing javascript?
It talks about using Python callbacks in Javascript functions.

Anvil Docs | Accessing Javascript

We added a feature just for this type of issue. There is a decorator you can use.

    @anvil.js.report_exceptions
    def my_callback(self, *args):
        ...

The decorator makes sure that errors in your python code get reported in the usual way.
The problem with using callbacks is that anvil loses some control of the code.
The Javascript library might handle the exception in its own way.

It can also be useful to run the app in a new tab and open up the chrome console to see if there’s any additional error messages from Javascript.

It’s also on our list to improve the [An internal error has occurred] message to be more informative.

3 Likes

A post was split to a new topic: Anvil.js.report_exceptions - suspension error