Added generalized error exception handling