I found a hack that works for me. Setting an error handlers log level to 0 only allows error messages through. Overwriting the MessageHandler's print method then allows to react to the error. This workaround is definitely a hack. If anyone has any better suggestions, I'd be happy to accept a different answer.
class ErrorCatchingCoinMessageHandler: public CoinMessageHandler {
public:
ErrorCatchingCoinMessageHandler()
: CoinMessageHandler() {
// Would be nice to also overwrite setLogLevel to avoid later changes
// but its not virtual
setLogLevel(0);
}
virtual int print() __attribute__((noreturn)) {
CoinMessageHandler::print();
abort(); // or throw a CoinError
}
};
// Use it like this
lp_solver->passInMessageHandler(new ErrorCatchingCoinMessageHandler());