handled exception and added  HTTP responses in REST api