added logic to capture more specific error information