Improved specific exception handling