1
0
Fork 0

Change JSBSim MatrixException base type

Make this exception inherit std::runtime_exception, so that it’s
caught by the ‘normal’ exception cases in FG boostrap.cxx

This is the only exception I can find in the codebase, which does not
inherit from either std::exception or std::string, so this is to fix
‘unknown exception’ errors reported in the wild.

Sentry-Id: FLIGHTGEAR-1C
This commit is contained in:
James Turner 2021-01-04 11:34:48 +00:00
parent 984e88bddd
commit a9323432d0
2 changed files with 7 additions and 8 deletions

View file

@ -437,9 +437,7 @@ FGMatrix33 FGMatrix33::operator/(const double scalar) const
Quot.data[5] = data[5] * tmp;
Quot.data[8] = data[8] * tmp;
} else {
MatrixException mE;
mE.Message = "Attempt to divide by zero in method FGMatrix33::operator/(const double scalar)";
throw mE;
throw MatrixException{"Attempt to divide by zero in method FGMatrix33::operator/(const double scalar)"};
}
return Quot;
}
@ -460,9 +458,7 @@ FGMatrix33& FGMatrix33::operator/=(const double scalar)
data[5] *= tmp;
data[8] *= tmp;
} else {
MatrixException mE;
mE.Message = "Attempt to divide by zero in method FGMatrix33::operator/=(const double scalar)";
throw mE;
throw MatrixException{"Attempt to divide by zero in method FGMatrix33::operator/=(const double scalar)"};
}
return *this;
}

View file

@ -42,6 +42,7 @@ INCLUDES
#include <string>
#include <iosfwd>
#include <stdexcept>
#include "FGColumnVector3.h"
@ -64,10 +65,12 @@ CLASS DOCUMENTATION
DECLARATION: MatrixException
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class MatrixException //: public FGJSBBase
// changed by James to inherit std::runtime_error, so that if this
// gets thrown, we can actually catch it.
class MatrixException : public std::runtime_error
{
public:
std::string Message;
MatrixException(const std::string& msg) : std::runtime_error{msg} { }
};
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%