Better way of handling error messages