Adding error reporting for better debugging whilst developing.