#3 Refactor error handling into class structure