Added rudimentary logging functionality when errors are encountered.