# Error handling

**URL:** <https://community.homey.app/t/error-handling/34925>\
**Category:** Developers\
**Tags:** app\
**Created:** [September 22, 2020, 9:21am UTC](https://community.homey.app/t/error-handling/34925 "2020-09-22T09:21:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Edling](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/christopher_edling/32/29169_2.png) [@Christopher\_Edling](https://community.homey.app/u/Christopher_Edling)\
**Post date:** [September 22, 2020, 9:21am UTC](https://community.homey.app/t/error-handling/34925/1 "2020-09-22T09:21:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Some1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/some1/32/8283_2.png) [@Some1](https://community.homey.app/u/Some1)\
**Post date:** [September 22, 2020, 10:50am UTC](https://community.homey.app/t/error-handling/34925/2 "2020-09-22T10:50:50Z")

</div>

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

> **[App Development Guidelines - Homey Apps SDK v2 Documentation](https://apps-sdk-v2.developer.athom.com/tutorial-App%20Development%20Guidelines.html)**

Is that what you mean?

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [September 22, 2020, 11:03am UTC](https://community.homey.app/t/error-handling/34925/3 "2020-09-22T11:03:37Z")

</div>

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

> All apps can take benefit of [homey-log](https://www.npmjs.com/package/homey-log) which integrates [Sentry](https://sentry.io/features/) (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.

---

<div class="post-metadata">

**Author:** ![Christopher\_Edling](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/christopher_edling/32/29169_2.png) [@Christopher\_Edling](https://community.homey.app/u/Christopher_Edling)\
**Post date:** [September 22, 2020, 12:37pm UTC](https://community.homey.app/t/error-handling/34925/4 "2020-09-22T12:37:21Z")

</div>

Thanks!  
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.

---

<div class="post-metadata">

**Author:** ![Christopher\_Edling](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/christopher_edling/32/29169_2.png) [@Christopher\_Edling](https://community.homey.app/u/Christopher_Edling)\
**Post date:** [September 22, 2020, 12:42pm UTC](https://community.homey.app/t/error-handling/34925/5 "2020-09-22T12:42:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [September 22, 2020, 1:32pm UTC](https://community.homey.app/t/error-handling/34925/6 "2020-09-22T13:32:10Z")

</div>

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.

Edit:  
If you are trying to track this down on your own Homey then you can put:  
`require('inspector').open(9222, '0.0.0.0', 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](https://community.homey.app/t/debug-app-code/33516)
