Error handling

I have developed an app and experience problems after it has been published for testing.

I have searched for information on how to best handle errors such as: try / catch, logging, crashes, etc. but can not find what I am looking for.

Is this documented somewhere or does everyone do it in their own way?
What is the best way to handle this?

There is a built in error handler function this.error for that as show here:

Is that what you mean?

Using homey-log is one method if you set up a sentry account:

All apps can take benefit of homey-log which integrates Sentry (a remote error tracking tool) into your app.

I like to create a log page in the app configuration screen. I generally log errors there by default plus have an option to turn on diagnostic logging to help track down difficult issues that users have with devices the I don’t own.

1 Like

I will look in to this. Maybe even take a look at some of your implementations to get sense of how it can be done.

1 Like

I’ve seen this but can I see this error message anywhere?

I can see it in the console while I’m developing, but when the app is in test state in the app store.
Where can I see the message then?

Messages that appear in the console for run, ‘might’ appear in the crash dump if you tap the Create Diagnostics Report in the app settings page. Those dumps will be available in your developers area by clicking on the Crashes number and then click on show stack trace.
I say ‘might’ because I often find the stack trace is empty for manually submitted reports.

If you are using homey-log then you can also write things out to Sentry.

If you look at some of my apps then you can see how I written a function to save the messages and display them in my log page.

If you are trying to track this down on your own Homey then you can put:
require('inspector').open(9222, '', false)
at the start of you app.js file then you can connect a debugger to the app at any time.
See Debug app code

1 Like