mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[C++] Extend IndexError's logic for empty arrays
This commit is contained in:
parent
dc018102fd
commit
fd1a4103c6
@ -180,7 +180,8 @@ public:
|
||||
* @param arrayName name of the corresponding array
|
||||
* @param m This is the value of the out-of-bounds index.
|
||||
* @param mmax This is the maximum allowed value of the index. The
|
||||
* minimum allowed value is assumed to be 0.
|
||||
* minimum allowed value is assumed to be 0. The special
|
||||
* value npos indicates that the array is empty.
|
||||
*/
|
||||
IndexError(const string& func, const string& arrayName, size_t m, size_t mmax) :
|
||||
CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}
|
||||
|
@ -72,6 +72,10 @@ string ArraySizeError::getMessage() const
|
||||
|
||||
string IndexError::getMessage() const
|
||||
{
|
||||
if (mmax_ == npos) {
|
||||
return fmt::format("IndexError: index {} given, but array{} is empty.",
|
||||
m_, arrayName_.empty() ? arrayName_ : " "+arrayName_);
|
||||
}
|
||||
if (arrayName_ == "") {
|
||||
return fmt::format("IndexError: {} outside valid range of 0 to {}.", m_, mmax_);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user