Capture output for better error reporting