throwing up correct exception when there is an XG error
merged with branch