Hey,
I'm developing a project using Node.js at the backed, with that I'm also using JSON to pass data to and from clients over web sockets. The problem I have is that if an invalid string was sent to the server (easily done by the user messing with the JavaScript console) then it would crash the server while trying to parse it.
The current method I have in place for preventing this occurrence is using a try/catch statement.
My question is, is there a more proper way of checking if a string is parsable? Also, is the use of try/catch statements good practice or are they meant only for debugging?
Thank-you.