adding exception handling method for rest calls