Skip to content

Commit

Permalink
Rename JSBBaseException to BaseException.
Browse files Browse the repository at this point in the history
The exception is defined within the namespace `JSBSim` so there is no need to prepend the exception name with `JSB` to avoid name clashes.
  • Loading branch information
bcoconni committed Feb 5, 2022
1 parent 8852bf5 commit 59c0bd9
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions python/ExceptionManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

// Pointers to Python exception classes.
// Their initialization take place in jsbsim.pyx
PyObject* jsbbase_error;
PyObject* base_error;
PyObject* trimfailure_error;
PyObject* geographic_error;
PyObject* matrix_error;
Expand All @@ -49,8 +49,8 @@ void convertJSBSimToPyExc()
catch (const JSBSim::TableException& e) {
PyErr_SetString(table_error, e.what());
}
catch (const JSBSim::JSBBaseException& e) {
PyErr_SetString(jsbbase_error, e.what());
catch (const JSBSim::BaseException& e) {
PyErr_SetString(base_error, e.what());
}
catch (const JSBSim::FloatingPointException& e) {
PyErr_SetString(e.getPyExc(), e.what());
Expand Down
2 changes: 1 addition & 1 deletion python/jsbsim.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ from libcpp.vector cimport vector
from cpython.ref cimport PyObject

cdef extern from "ExceptionManagement.h":
cdef PyObject* jsbbase_error
cdef PyObject* base_error
cdef PyObject* trimfailure_error
cdef PyObject* geographic_error
cdef PyObject* matrix_error
Expand Down
12 changes: 6 additions & 6 deletions python/jsbsim.pyx.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@ import numpy
__version__='${PROJECT_VERSION}'


class JSBBaseError(RuntimeError):
class BaseError(RuntimeError):
"""JSBSim base exception class."""
pass


class TrimFailureError(JSBBaseError):
class TrimFailureError(BaseError):
"""Exception class for trim failures."""
pass


class GeographicError(JSBBaseError):
class GeographicError(BaseError):
"""Exception class for geographic computation errors."""
pass


class MatrixError(JSBBaseError):
class MatrixError(BaseError):
"""Exception class for matrix errors."""
pass


class TableError(JSBBaseError):
class TableError(BaseError):
"""Exception class for table errors."""
pass


jsbbase_error = <PyObject*>JSBBaseError
base_error = <PyObject*>BaseError
trimfailure_error = <PyObject*>TrimFailureError
geographic_error = <PyObject*>GeographicError
matrix_error = <PyObject*>MatrixError
Expand Down
4 changes: 2 additions & 2 deletions src/FGFDMExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, std::shared_ptr<unsigned int> fdmc
cerr << endl << "Caught error: " << msg << endl;
throw;
}
catch (const JSBBaseException& e) {
catch (const BaseException& e) {
cout << endl << "Caught error: " << e.what() << endl;
throw;
}
Expand Down Expand Up @@ -1171,7 +1171,7 @@ bool FGFDMExec::ReadChild(Element* el)
const string s(" No location was found for this child object!");
cerr << location->ReadFrom() << endl << highint << fgred
<< s << reset << endl;
throw JSBBaseException(s);
throw BaseException(s);
}

Element* orientation = el->FindElement("orient");
Expand Down
4 changes: 2 additions & 2 deletions src/FGFDMExec.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class FGInput;
class FGPropulsion;
class FGMassBalance;

class TrimFailureException : public JSBBaseException {
class TrimFailureException : public BaseException {
public:
TrimFailureException(const std::string& msg) : JSBBaseException(msg) {}
TrimFailureException(const std::string& msg) : BaseException(msg) {}
};

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
14 changes: 7 additions & 7 deletions src/FGJSBBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ FORWARD DECLARATIONS

namespace JSBSim {

class JSBBaseException : public std::runtime_error {
class BaseException : public std::runtime_error {
public:
JSBBaseException(const std::string& msg) : std::runtime_error(msg) {}
BaseException(const std::string& msg) : std::runtime_error(msg) {}
};

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -269,15 +269,15 @@ class FGJSBBase {
static double PitotTotalPressure(double mach, double p);

/** Compute the Mach number from the differential pressure (qc) and the
* static pressure. Based on the formulas in the US Air Force Aircraft
* static pressure. Based on the formulas in the US Air Force Aircraft
* Performance Flight Testing Manual (AFFTC-TIH-99-01).
* @param qc The differential/impact pressure
* @param p Pressure in psf
* @return The Mach number */
static double MachFromImpactPressure(double qc, double p);

/** Calculate the calibrated airspeed from the Mach number. Based on the
* formulas in the US Air Force Aircraft Performance Flight Testing
* formulas in the US Air Force Aircraft Performance Flight Testing
* Manual (AFFTC-TIH-99-01).
* @param mach The Mach number
* @param p Pressure in psf
Expand All @@ -286,7 +286,7 @@ class FGJSBBase {
static double VcalibratedFromMach(double mach, double p);

/** Calculate the Mach number from the calibrated airspeed.Based on the
* formulas in the US Air Force Aircraft Performance Flight Testing
* formulas in the US Air Force Aircraft Performance Flight Testing
* Manual (AFFTC-TIH-99-01).
* @param vcas The calibrated airspeed (CAS) in ft/s
* @param p Pressure in psf
Expand Down Expand Up @@ -327,13 +327,13 @@ class FGJSBBase {
static bool EqualToRoundoff(double a, float b) {
return EqualToRoundoff((float)a, b);
}

/** Constrain a value between a minimum and a maximum value.
*/
static constexpr double Constrain(double min, double value, double max) {
return value<min?(min):(value>max?(max):(value));
}

static constexpr double sign(double num) {return num>=0.0?1.0:-1.0;}

static double GaussianRandomNumber(void);
Expand Down
6 changes: 3 additions & 3 deletions src/initialization/FGInitialCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,14 +1017,14 @@ bool FGInitialCondition::Load(const SGPath& rstfile, bool useStoredPath)
stringstream s;
s << "File: " << init_file_name << " could not be read.";
cerr << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}

if (document->GetName() != string("initialize")) {
stringstream s;
s << "File: " << init_file_name << " is not a reset file.";
cerr << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}

double version = HUGE_VAL;
Expand All @@ -1038,7 +1038,7 @@ bool FGInitialCondition::Load(const SGPath& rstfile, bool useStoredPath)
} else if (version >= 3.0) {
const string s("Only initialization file formats 1 and 2 are currently supported");
cerr << document->ReadFrom() << endl << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
} else if (version >= 2.0) {
result = Load_v2(document);
} else if (version >= 1.0) {
Expand Down
4 changes: 2 additions & 2 deletions src/input_output/FGScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ void FGScript::Debug(int from)
s << " An attempt has been made to access a non-existent property" << endl
<< " in this event. Please check the property names used, spelling, etc.";
cerr << fgred << highint << endl << s.str() << reset << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
} else {
cout << endl << " set " << Events[i].SetParamName[j]
<< " to function value (Late Bound)";
Expand All @@ -621,7 +621,7 @@ void FGScript::Debug(int from)
s << " An attempt has been made to access a non-existent property" << endl
<< " in this event. Please check the property names used, spelling, etc.";
cerr << fgred << highint << endl << s.str() << reset << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
} else {
cout << endl << " set " << Events[i].SetParamName[j]
<< " to function value (Late Bound)";
Expand Down
4 changes: 2 additions & 2 deletions src/math/FGMatrix33.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ CLASS DOCUMENTATION
DECLARATION: MatrixException
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

class MatrixException : public JSBBaseException
class MatrixException : public BaseException
{
public:
MatrixException(const std::string& msg) : JSBBaseException{msg} { }
MatrixException(const std::string& msg) : BaseException{msg} { }
};

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
4 changes: 2 additions & 2 deletions src/math/FGTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio
DECLARATION: TableException
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

class TableException : public JSBBaseException
class TableException : public BaseException
{
public:
TableException(const std::string& msg) : JSBBaseException{msg} { }
TableException(const std::string& msg) : BaseException{msg} { }
};

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
8 changes: 4 additions & 4 deletions src/models/FGAerodynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ bool FGAerodynamics::Run(bool Holding)
s << " A proper axis type has NOT been selected. Check "
<< "your aerodynamics definition.";
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
}
// Calculate aerodynamic reference point shift, if any. The shift takes place
Expand Down Expand Up @@ -281,7 +281,7 @@ bool FGAerodynamics::Run(bool Holding)
s << " A proper axis type has NOT been selected. Check "
<< "your aerodynamics definition.";
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
}

Expand Down Expand Up @@ -460,7 +460,7 @@ void FGAerodynamics::DetermineAxisSystem(Element* document)
<< endl << " An unknown axis type, " << axis << " has been specified"
<< " in the aircraft configuration file.";
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
axis_element = document->FindNextElement("axis");
}
Expand Down Expand Up @@ -508,7 +508,7 @@ void FGAerodynamics::ProcessAxesNameAndFrame(eAxisType& axisType, const string&
stringstream s;
s << " Unknown axis frame type of - " << frame;
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/models/FGGasCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
} else {
const string s("Fatal Error: No location found for this gas cell.");
cerr << el->ReadFrom() << endl << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
}
if ((el->FindElement("x_radius") || el->FindElement("x_width")) &&
(el->FindElement("y_radius") || el->FindElement("y_width")) &&
Expand Down Expand Up @@ -140,7 +140,7 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
} else {
const string s("Fatal Error: Gas cell shape must be given.");
cerr << el->ReadFrom() << endl << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
}
if (el->FindElement("max_overpressure")) {
MaxOverpressure = el->FindElementValueAsNumberConvertTo("max_overpressure",
Expand Down Expand Up @@ -521,7 +521,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num,
} else {
const string s("Fatal Error: No location found for this ballonet.");
cerr << el->ReadFrom() << endl << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
}
if ((el->FindElement("x_radius") || el->FindElement("x_width")) &&
(el->FindElement("y_radius") || el->FindElement("y_width")) &&
Expand Down Expand Up @@ -573,7 +573,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num,
} else {
const string s("Fatal Error: Ballonet shape must be given.");
cerr << el->ReadFrom() << endl << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
}
if (el->FindElement("max_overpressure")) {
MaxOverpressure = el->FindElementValueAsNumberConvertTo("max_overpressure",
Expand Down
2 changes: 1 addition & 1 deletion src/models/FGLGear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs&
stringstream s;
s << "No location given for contact " << name;
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
SetTransformType(FGForce::tCustom);

Expand Down
2 changes: 1 addition & 1 deletion src/models/FGMassBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void FGMassBalance::AddPointMass(Element* el)
s << el->ReadFrom() << "Pointmass " << pointmass_name
<< " has no location.";
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}

double w = el->FindElementValueAsNumberConvertTo("weight", "LBS");
Expand Down
6 changes: 3 additions & 3 deletions src/models/FGPropagate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,19 +1031,19 @@ void FGPropagate::Debug(int from)
stringstream s;
s << "Vehicle rotation rate is excessive (>1000 rad/sec): " << VState.vPQR.Magnitude();
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
if (fabs(VState.vUVW.Magnitude()) > 1.0e10) {
stringstream s;
s << "Vehicle velocity is excessive (>1e10 ft/sec): " << VState.vUVW.Magnitude();
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
if (fabs(GetDistanceAGL()) > 1e10) {
stringstream s;
s << "Vehicle altitude is excessive (>1e10 ft): " << GetDistanceAGL();
cerr << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/flight_control/FGKinemat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ FGKinemat::FGKinemat(FGFCS* fcs, Element* element)
s << "Kinematic component " << Name
<< " must have more than 1 setting element";
cerr << element->ReadFrom() << endl << s.str() << endl;
throw JSBBaseException(s.str());
throw BaseException(s.str());
}

bind(element, fcs->GetPropertyManager().get());
Expand Down
8 changes: 4 additions & 4 deletions src/models/propulsion/FGBrushLessDCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ FGBrushLessDCMotor::FGBrushLessDCMotor(FGFDMExec* exec, Element* el, int engine_
else {
cerr << el->ReadFrom()
<< "<maxvolts> is a mandatory parameter" << endl;
throw JSBBaseException("Missing parameter");
throw BaseException("Missing parameter");
}

if (el->FindElement("velocityconstant"))
Kv = el->FindElementValueAsNumber("velocityconstant");
else {
cerr << el->ReadFrom()
<< "<velocityconstant> is a mandatory parameter" << endl;
throw JSBBaseException("Missing parameter");
throw BaseException("Missing parameter");
}

if (el->FindElement("coilresistance"))
CoilResistance = el->FindElementValueAsNumberConvertTo("coilresistance", "OHMS");
else {
cerr << el->ReadFrom()
<< "<coilresistance> is a mandatory parameter" << endl;
throw JSBBaseException("Missing parameter");
throw BaseException("Missing parameter");
}
if (el->FindElement("noloadcurrent"))
ZeroTorqueCurrent = el->FindElementValueAsNumberConvertTo("noloadcurrent", "AMPERES");
else {
cerr << el->ReadFrom()
<< "<noloadcurrent> is a mandatory parameter" << endl;
throw JSBBaseException("Missing parameter");
throw BaseException("Missing parameter");
}

double MaxCurrent = MaxVolts / CoilResistance + ZeroTorqueCurrent;
Expand Down
2 changes: 1 addition & 1 deletion src/models/propulsion/FGForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const FGMatrix33& FGForce::Transform(void) const
{
const string s("Unrecognized tranform requested from FGForce::Transform()");
cout << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/propulsion/FGNozzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num)
else {
const string s("Fatal Error: Nozzle exit area must be given in nozzle config file.");
cerr << s << endl;
throw JSBBaseException(s);
throw BaseException(s);
}

Thrust = 0;
Expand Down
Loading

0 comments on commit 59c0bd9

Please sign in to comment.