You should use CV_Error instead of cv::error. CV_Error and CV_Assert are implemented through cv::error and they are easier to use.