Added additional error handling to the domain module.