Created API Controller with extracted error handling