Making the error handling piece of code a little bit nicer to read