error handling for rest route