adding functionality for capturing an error