# Set global error handler
def handle_error(err):
print('err', err)
send_rollbar_message(str(err))
raise err
anvil.set_default_error_handling(handle_error)
Normally this works fine. The funny thing now is that the error handler is called by Anvil with the error being None.
All this is in the context of an elusive “[An internal error has occurred]” error in the app console. The app logs are not very helpful either with “: Unknown error”.
Already tried that (sorry, I wasn’t clear about that): the error occurs but I have no clue where it happens. No line numbers, no error code.
The app seems to continue normally.
Are you using any JavaScript libraries? When I was attempting (very poorly) to use some JS libraries, some errors weren’t transferred through and there was no Error messages in the logs. Took me an entire day to work out what was going on
I do: PAHO MQTT 1.1.0. However, I sprinkled all callback functions with @anvil.js.report_exceptions (very useful!), but it still won’t catch my ghost error. I inserted print statements in my code to try to locate the region of code that caused the error. No luck.
It seems I’d need something like @anvil.js.report_exceptions that works globally.
Hmm. Do you get anything from the print statements?
What about any uplink scripts?
The thing that I know gave me dramas like this was an uplink script that was running selenium that wasn’t reporting back from PyCharm.
Once I realised it was the uplink script, debugging it locally sorted it out.
Per your suggestion I put a blanket Exception handler in the uplink function. Nothing.
Also the error seems to occur when starting the app/opening the main form. So the uplink code is not yet called.
If it’s a javascript error from a javascript library it might be necessary to run the app in a new tab and open up developer tools to see if there are any javascript error reports in the browser console.
It might also be the stage to see if you can create a clone that consistently produces the bug.
I usually run app in a new tab (The other view options of the new editor are too cramped IMO).
I just had a look at the console. I just see a bunch of anvil errors:
I have noticed that the error only occurs on loading the app (and not even always). Today it occurred again. This is what is shown on the JS console (errors only)