In the world of software, a lot can go wrong—especially if the software is complex and/or depends on third party services. It’s important that your software is prepared to withstand issues that could arise. Here are some tips that can help:

1. Always Have Logic in Place to Handle Errors


This may seem obvious, but this is something that really does get overlooked. One example is with making an AJAX request. Developers often assume that the request will never, ever fail, so they don’t write code to handle the scenario of the request failing.

Let’s say you’re on a website and you click a button to add a product to your cart. The website has been set up to add the product to your cart using AJAX (so you don’t have to leave the page). It has also been set up to show a spinning animation to let you know that something is happening. If the website has been set up to just assume that the request will be successful but then something goes wrong, you might be left with that spinning animation going forever and you will be left frustrated and/or confused.

2. Write Tests


Tests are essential for developing websites (or any kind of software) with confidence. If your website is even somewhat complicated, it’s easy for a small change to break something. It’s also common for a bug fix to actually create one or more new bugs! If you don’t have tests in place, it’s very easy to miss these issues.

Another thing tests are great for is testing how your website handles rare occurrences. For example, if your website allows users to log in using a third party service such as Twitter or Facebook, what happens when the website can’t communicate with Twitter and/or Facebook? If you have tests in place, you will know the answer.

3. Test on a Variety of Platforms


Web browsers are much better about adhering to web standards than they used to be. Despite this, there are still plenty of differences, and those differences can cause your website to break for some of your users. Thus, it’s important to test your website with a variety of web browsers.

Keep in mind that even if you know your website looks the way you want it to with a particular web browser on a particular operating system, that doesn’t guarantee that it will look the same with the same web browser on a different operating system. For example, font rendering differences could cause a set of links to appear wider on certain operating system / web browser combinations and maybe the last link in the set won’t be visible to some of your users. Thus, it’s important to test your website with a variety of operating systems.

4. Be Prepared to Handle All Kinds of User Input


You can never trust user input. People are imperfect, so they don’t read instructions, they forget things, and they overlook things. There are also some malicious people out there who might try to exploit a vulnerability that may or may not exist on your website. For these reasons, you have to be sure that whatever input the user gives you is given in the way you expect.

If you have a form with a required field, be sure to have server-side logic that ensures that the field truly is required. If you have a date field, be sure to have server-side logic that ensures that the value entered is a valid date. Those are just a couple of examples. If you don’t have this type of logic in place, it’s easy for users to cause an error to occur and it can also be a security risk.

5. Provide Informative Error Messages


Although you may have your website prepared to handle errors, if you don’t provide informative error messages to the user, you’re not much better off than you were. Remember that error messages are meant to be read by humans.

6. Provide Friendly 404/500/etc. Pages


Some might think that everybody knows that a 404 error means that the page couldn’t be found, so leaving the web server’s default 404 page in place should be fine. In reality, having a friendly 404 page (and 500 page, etc.) in place can make a big difference for your users. It’s more professional, too.

7. Log Errors and Monitor the Error Logs


If an error occurs on your website, will you find out about it if the user who experienced the error doesn’t report it to you? And if your answer is “yes”, how much time will pass between the time the error occurred and the time you find out about it?

Tools like Airbrake and Bugsnag are great for helping with error tracking.


If your website handles errors gracefully, it will make a world of difference to your users and help your website be more successful.