std::runtime except

 

class DataException:public std::runtime_error{
 public:
  /// <summary>
  /// Initializes a new instance of a DataException.
  /// </summary>
  /// <param name="message">The error message.</param>
  DataException(const std::string & message)
   :std::runtime_error(message){}

  /// <summary>
  /// Initializes a new instance of a DataException.
  /// </summary>
  /// <param name="message">The error message.</param>
  /// <param name="details">Error details to be appended to the message.</param>
  DataException(const std::string & message , const std::string & details)
   :std::runtime_error(message+": "+details){}
 };

 

 

static void NotEmpty(const std::string & value, const std::string & message="String is empty error."){
   if(value.length()==0){
    throw DataException(message);
   }
  }  

你可能感兴趣的:(std::runtime except)