Exception handling for input mismatch.