Refactoring SAM REST Service, update error handling