Skip to content

Commit

Permalink
Derive ElemAlreadyExists from std::runtime_error (#2614)
Browse files Browse the repository at this point in the history
`std::exception`'s constructors don't accept `std::strings`, so it's a
bit strange to override method `what`

https://en.cppreference.com/w/cpp/error/exception/exception
  • Loading branch information
flomnes authored Jan 30, 2025
1 parent caa5406 commit ed5e579
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/solver/modeler/ortoolsImpl/linearProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ OrtoolsLinearProblem::OrtoolsLinearProblem(bool isMip, const std::string& solver
objective_ = mpSolver_->MutableObjective();
}

class ElemAlreadyExists: public std::exception
class ElemAlreadyExists: public std::runtime_error
{
public:
const char* what() const noexcept override
explicit ElemAlreadyExists():
std::runtime_error("Element name already exists in linear problem")
{
return "Element name already exists in linear problem";
}
};

Expand Down

0 comments on commit ed5e579

Please sign in to comment.