When writing code there are a number of reasons that may cause errors, for example: A problem with network connection A user might have entered an invalid value in a…