Minor refactoring: implement error setter and remove duplicated code
Add one more TODO for future implementation