0

When debugging my app I do the following.

.catch(error => { console.log("error is", error); }

Which is is fine but what should I do in production? I don't really want to leave all these console.logs in.

Thanks.

Barmar
  • 741,623
  • 53
  • 500
  • 612
TommyD
  • 913
  • 3
  • 17
  • 32
  • 1
    What do you want to do instead? – Barmar Jan 15 '19 at 21:26
  • 1
    There aren't really many choices. Either you ignore the error, throw an exception, or log a message. – Barmar Jan 15 '19 at 21:28
  • 1
    Then take it out--what you report to the user, and how, is up to you. If it's something that could reasonably be recovered from, like a form submit failed, you can display a message and have them try again. If it's completely out of the user's hands, send something to your back-end logging. – Dave Newton Jan 15 '19 at 21:31
  • *Why* don't you want to leave all the log statements in? – Bergi Jan 15 '19 at 22:23
  • I just think it is a bit messy and don't really want users to see the errors. Suppose I could just suppress them https://stackoverflow.com/questions/7500811/how-do-i-disable-console-log-when-i-am-not-debugging – TommyD Jan 16 '19 at 09:31

1 Answers1

1

Usually, in production, we would use some error logging mechanism and the one I used the most ELMAH. Or implement some other logging mechanism by yourself and log it so you can check it whenever you wanted.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Arjun
  • 56
  • 2
  • Could you describe how to pass client-side errors to ELMAH, or link it's relevant documentation? – Bergi Jan 15 '19 at 22:23
  • I think this is a good answer lots of paid option or https://www.bugsnag.com/pricing/ where you get a free option to log basic errors. – TommyD Jan 16 '19 at 09:29