Replace generic exception with a specific one.