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

View file

@ -42,6 +42,7 @@ INCLUDES
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
#include <stdexcept>
#include "FGColumnVector3.h" #include "FGColumnVector3.h"
@ -64,10 +65,12 @@ CLASS DOCUMENTATION
DECLARATION: MatrixException 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: public:
std::string Message; MatrixException(const std::string& msg) : std::runtime_error{msg} { }
}; };
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%