Added more exception handling to REST API