Added error handling to setDimensions()