Skip to content

Commit 6e727ff

Browse files
K20shoresclaude
andcommitted
Address PR review comments on MicmException
- Change category_ member from string_view to const char* to avoid dangling reference risk when passing temporaries - Add direct include of micm_exception.hpp to sparse_matrix.hpp and sparse_matrix_standard_ordering_compressed_sparse_row.hpp - Fix matrix.hpp bug where constructed msg was dropped (passed "" instead) - Fill in all empty exception message strings across matrix, sparse matrix, constraint, rate constant, and state throw sites Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bfcfba0 commit 6e727ff

11 files changed

+42
-41
lines changed

include/micm/constraint/equilibrium_constraint.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,28 @@ namespace micm
6161
{
6262
if (reactants_.empty())
6363
{
64-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_REACTANTS, "");
64+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_REACTANTS, "Equilibrium constraint requires at least one reactant");
6565
}
6666
if (products_.empty())
6767
{
68-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_PRODUCTS, "");
68+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_PRODUCTS, "Equilibrium constraint requires at least one product");
6969
}
7070
if (equilibrium_constant_ <= 0)
7171
{
72-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_EQUILIBRIUM_CONSTANT, "");
72+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_EQUILIBRIUM_CONSTANT, "Equilibrium constant must be positive");
7373
}
7474
for (const auto& r : reactants_)
7575
{
7676
if (r.coefficient_ <= 0)
7777
{
78-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY, "");
78+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY, "Stoichiometric coefficients must be positive");
7979
}
8080
}
8181
for (const auto& p : products_)
8282
{
8383
if (p.coefficient_ <= 0)
8484
{
85-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY, "");
85+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY, "Stoichiometric coefficients must be positive");
8686
}
8787
}
8888

include/micm/process/rate_constant/surface_rate_constant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace micm
106106

107107
inline double SurfaceRateConstant::Calculate(const Conditions& conditions) const
108108
{
109-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_RATE_CONSTANT, MICM_RATE_CONSTANT_ERROR_CODE_MISSING_ARGUMENTS_FOR_SURFACE_RATE_CONSTANT, "");
109+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_RATE_CONSTANT, MICM_RATE_CONSTANT_ERROR_CODE_MISSING_ARGUMENTS_FOR_SURFACE_RATE_CONSTANT, "Missing required arguments for surface rate constant");
110110
}
111111

112112
inline double SurfaceRateConstant::Calculate(

include/micm/process/rate_constant/user_defined_rate_constant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace micm
6969

7070
inline double UserDefinedRateConstant::Calculate(const Conditions& conditions) const
7171
{
72-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_RATE_CONSTANT, MICM_RATE_CONSTANT_ERROR_CODE_MISSING_ARGUMENTS_FOR_USER_DEFINED_RATE_CONSTANT, "");
72+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_RATE_CONSTANT, MICM_RATE_CONSTANT_ERROR_CODE_MISSING_ARGUMENTS_FOR_USER_DEFINED_RATE_CONSTANT, "Missing required arguments for user-defined rate constant");
7373
}
7474

7575
inline double UserDefinedRateConstant::Calculate(

include/micm/solver/state.inl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ namespace micm
427427
if (var == variable_map_.end())
428428
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_UNKNOWN_SPECIES, species.name_);
429429
if (variables_.NumRows() != 1)
430-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "");
430+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "Concentration vector size does not match the number of grid cells");
431431
variables_[0][variable_map_[species.name_]] = concentration;
432432
}
433433

@@ -446,7 +446,7 @@ namespace micm
446446
if (var == variable_map_.end())
447447
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_UNKNOWN_SPECIES, species.name_);
448448
if (variables_.NumRows() != concentration.size())
449-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "");
449+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "Concentration vector size does not match the number of grid cells");
450450
std::size_t i_species = variable_map_[species.name_];
451451
for (std::size_t i = 0; i < variables_.NumRows(); ++i)
452452
variables_[i][i_species] = concentration[i];
@@ -467,7 +467,7 @@ namespace micm
467467
if (var == variable_map_.end())
468468
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_UNKNOWN_SPECIES, element);
469469
if (variables_.NumRows() != 1)
470-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "");
470+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "Concentration vector size does not match the number of grid cells");
471471
variables_[0][variable_map_[element]] = concentration;
472472
}
473473

@@ -486,7 +486,7 @@ namespace micm
486486
if (var == variable_map_.end())
487487
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_UNKNOWN_SPECIES, element);
488488
if (variables_.NumRows() != concentration.size())
489-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "");
489+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CONCENTRATION_COUNT_MULTIGRID, "Concentration vector size does not match the number of grid cells");
490490
std::size_t i_species = variable_map_[element];
491491
for (std::size_t i = 0; i < variables_.NumRows(); ++i)
492492
variables_[i][i_species] = concentration[i];
@@ -502,10 +502,10 @@ namespace micm
502502
UnsafelySetCustomRateParameters(const std::vector<std::vector<double>>& parameters)
503503
{
504504
if (parameters.size() != variables_.NumRows())
505-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT_MULTIGRID, "");
505+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT_MULTIGRID, "Custom rate parameter vector size does not match the number of grid cells");
506506

507507
if (parameters[0].size() != custom_rate_parameters_.NumColumns())
508-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT, "");
508+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT, "Custom rate parameter count does not match the number of rate constants");
509509

510510
for (size_t i = 0; i < number_of_grid_cells_; ++i)
511511
{
@@ -542,7 +542,7 @@ namespace micm
542542
if (param == custom_rate_parameter_map_.end())
543543
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_UNKNOWN_RATE_CONSTANT_PARAMETER, label);
544544
if (custom_rate_parameters_.NumRows() != 1)
545-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT_MULTIGRID, "");
545+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT_MULTIGRID, "Custom rate parameter vector size does not match the number of grid cells");
546546
custom_rate_parameters_[0][param->second] = value;
547547
}
548548

@@ -561,7 +561,7 @@ namespace micm
561561
if (param == custom_rate_parameter_map_.end())
562562
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_UNKNOWN_RATE_CONSTANT_PARAMETER, label);
563563
if (custom_rate_parameters_.NumRows() != values.size())
564-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT_MULTIGRID, "");
564+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_STATE, MICM_STATE_ERROR_CODE_INVALID_CUSTOM_RATE_PARAM_COUNT_MULTIGRID, "Custom rate parameter vector size does not match the number of grid cells");
565565
for (std::size_t i = 0; i < custom_rate_parameters_.NumRows(); ++i)
566566
custom_rate_parameters_[i][param->second] = values[i];
567567
}

include/micm/util/matrix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace micm
230230
{
231231
std::string msg = "In matrix constructor from std::vector<std::vector>. Got " +
232232
std::to_string(other[x].size()) + " columns, but expected " + std::to_string(y_dim);
233-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_INVALID_VECTOR, "");
233+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_INVALID_VECTOR, msg);
234234
}
235235
for (std::size_t y{}; y < y_dim; ++y)
236236
{

include/micm/util/micm_exception.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <stdexcept>
88
#include <string>
9-
#include <string_view>
109

1110
namespace micm
1211
{
@@ -20,10 +19,10 @@ namespace micm
2019
struct MicmException : public std::runtime_error
2120
{
2221
MicmSeverity severity_;
23-
std::string_view category_;
22+
const char* category_;
2423
int code_;
2524

26-
MicmException(MicmSeverity severity, std::string_view category, int code, const std::string& message)
25+
MicmException(MicmSeverity severity, const char* category, int code, const std::string& message)
2726
: std::runtime_error(message),
2827
severity_(severity),
2928
category_(category),

include/micm/util/sparse_matrix.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
#pragma once
44

5+
#include <micm/util/micm_exception.hpp>
56
#include <micm/util/sparse_matrix_standard_ordering.hpp>
67
#include <micm/util/view_category.hpp>
78

@@ -290,7 +291,7 @@ namespace micm
290291
std::size_t VectorIndex(std::size_t row, std::size_t column) const
291292
{
292293
if (number_of_blocks_ != 1)
293-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_MISSING_BLOCK_INDEX, "");
294+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_MISSING_BLOCK_INDEX, "Matrix has multiple blocks; use the (block, row, col) overload of VectorIndex instead");
294295
return VectorIndex(0, row, column);
295296
}
296297

@@ -686,7 +687,7 @@ namespace micm
686687
SparseMatrixBuilder& WithElement(std::size_t x, std::size_t y)
687688
{
688689
if (x >= block_size_ || y >= block_size_)
689-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
690+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
690691
non_zero_elements_.insert(std::make_pair(x, y));
691692
return *this;
692693
}

include/micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ namespace micm
7070
std::size_t VectorIndex(std::size_t number_of_blocks, std::size_t block, std::size_t row, std::size_t column) const
7171
{
7272
if (column >= column_start_.size() - 1 || row >= column_start_.size() - 1 || block >= number_of_blocks)
73-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
73+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
7474
auto begin = std::next(column_ids_.begin(), column_start_[column]);
7575
auto end = std::next(column_ids_.begin(), column_start_[column + 1]);
7676
auto elem = std::find(begin, end, row);
7777
if (elem == end)
78-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "");
78+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "Zero element access");
7979
return std::size_t{ (elem - column_ids_.begin()) + block * column_ids_.size() };
8080
}
8181

@@ -98,12 +98,12 @@ namespace micm
9898
std::size_t VectorIndexFromRowColumn(std::size_t row, std::size_t col) const
9999
{
100100
if (col >= column_start_.size() - 1 || row >= column_start_.size() - 1)
101-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
101+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
102102
auto begin = std::next(column_ids_.begin(), column_start_[col]);
103103
auto end = std::next(column_ids_.begin(), column_start_[col + 1]);
104104
auto elem = std::find(begin, end, row);
105105
if (elem == end)
106-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "");
106+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "Zero element access");
107107
return std::distance(column_ids_.begin(), elem);
108108
}
109109

@@ -409,7 +409,7 @@ namespace micm
409409
bool IsZero(std::size_t row, std::size_t column) const
410410
{
411411
if (column >= column_start_.size() - 1 || row >= column_start_.size() - 1)
412-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
412+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
413413
auto begin = std::next(column_ids_.begin(), column_start_[column]);
414414
auto end = std::next(column_ids_.begin(), column_start_[column + 1]);
415415
auto elem = std::find(begin, end, row);

include/micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
#pragma once
44

5+
#include <micm/util/micm_exception.hpp>
56
#include <micm/util/view_category.hpp>
67

78
#include <algorithm>
@@ -69,12 +70,12 @@ namespace micm
6970
std::size_t VectorIndex(std::size_t number_of_blocks, std::size_t block, std::size_t row, std::size_t column) const
7071
{
7172
if (row >= row_start_.size() - 1 || column >= row_start_.size() - 1 || block >= number_of_blocks)
72-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
73+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
7374
auto begin = std::next(row_ids_.begin(), row_start_[row]);
7475
auto end = std::next(row_ids_.begin(), row_start_[row + 1]);
7576
auto elem = std::find(begin, end, column);
7677
if (elem == end)
77-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "");
78+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "Zero element access");
7879
return std::size_t{ (elem - row_ids_.begin()) + block * row_ids_.size() };
7980
}
8081

@@ -96,12 +97,12 @@ namespace micm
9697
std::size_t VectorIndexFromRowColumn(std::size_t row, std::size_t col) const
9798
{
9899
if (row >= row_start_.size() - 1 || col >= row_start_.size() - 1)
99-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
100+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
100101
auto begin = std::next(row_ids_.begin(), row_start_[row]);
101102
auto end = std::next(row_ids_.begin(), row_start_[row + 1]);
102103
auto elem = std::find(begin, end, col);
103104
if (elem == end)
104-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "");
105+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "Zero element access");
105106
return std::distance(row_ids_.begin(), elem);
106107
}
107108

@@ -401,7 +402,7 @@ namespace micm
401402
bool IsZero(std::size_t row, std::size_t column) const
402403
{
403404
if (row >= row_start_.size() - 1 || column >= row_start_.size() - 1)
404-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
405+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
405406
auto begin = std::next(row_ids_.begin(), row_start_[row]);
406407
auto end = std::next(row_ids_.begin(), row_start_[row + 1]);
407408
auto elem = std::find(begin, end, column);

include/micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ namespace micm
7676
std::size_t VectorIndex(std::size_t number_of_blocks, std::size_t block, std::size_t row, std::size_t column) const
7777
{
7878
if (column >= column_start_.size() - 1 || row >= column_start_.size() - 1 || block >= number_of_blocks)
79-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
79+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
8080
auto begin = std::next(column_ids_.begin(), column_start_[column]);
8181
auto end = std::next(column_ids_.begin(), column_start_[column + 1]);
8282
auto elem = std::find(begin, end, row);
8383
if (elem == end)
84-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "");
84+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "Zero element access");
8585
return std::size_t{ (elem - column_ids_.begin()) * L + block % L + (block / L) * L * column_ids_.size() };
8686
}
8787

@@ -109,12 +109,12 @@ namespace micm
109109
std::size_t VectorIndexFromRowColumn(std::size_t row, std::size_t col) const
110110
{
111111
if (col >= column_start_.size() - 1 || row >= column_start_.size() - 1)
112-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
112+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
113113
auto begin = std::next(column_ids_.begin(), column_start_[col]);
114114
auto end = std::next(column_ids_.begin(), column_start_[col + 1]);
115115
auto elem = std::find(begin, end, row);
116116
if (elem == end)
117-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "");
117+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ZERO_ELEMENT_ACCESS, "Zero element access");
118118
return std::distance(column_ids_.begin(), elem);
119119
}
120120

@@ -516,7 +516,7 @@ namespace micm
516516
bool IsZero(const std::size_t row, const std::size_t column) const
517517
{
518518
if (column >= column_start_.size() - 1 || row >= column_start_.size() - 1)
519-
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "");
519+
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_MATRIX, MICM_MATRIX_ERROR_CODE_ELEMENT_OUT_OF_RANGE, "Element out of range");
520520
auto begin = std::next(column_ids_.begin(), column_start_[column]);
521521
auto end = std::next(column_ids_.begin(), column_start_[column + 1]);
522522
auto elem = std::find(begin, end, row);

0 commit comments

Comments
 (0)