diff --git a/python/ExceptionManagement.h b/python/ExceptionManagement.h index 9903db916..2940c4c13 100644 --- a/python/ExceptionManagement.h +++ b/python/ExceptionManagement.h @@ -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; @@ -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()); diff --git a/python/jsbsim.pxd b/python/jsbsim.pxd index 86f726ea8..99335c268 100644 --- a/python/jsbsim.pxd +++ b/python/jsbsim.pxd @@ -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 diff --git a/python/jsbsim.pyx.in b/python/jsbsim.pyx.in index 92b009f51..0c226bf73 100644 --- a/python/jsbsim.pyx.in +++ b/python/jsbsim.pyx.in @@ -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 = JSBBaseError +base_error = BaseError trimfailure_error = TrimFailureError geographic_error = GeographicError matrix_error = MatrixError diff --git a/src/FGFDMExec.cpp b/src/FGFDMExec.cpp index 796e68d74..6eebb78c6 100644 --- a/src/FGFDMExec.cpp +++ b/src/FGFDMExec.cpp @@ -145,7 +145,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, std::shared_ptr fdmc cerr << endl << "Caught error: " << msg << endl; throw; } - catch (const JSBBaseException& e) { + catch (const BaseException& e) { cout << endl << "Caught error: " << e.what() << endl; throw; } @@ -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"); diff --git a/src/FGFDMExec.h b/src/FGFDMExec.h index 54b22d22b..30aa43514 100644 --- a/src/FGFDMExec.h +++ b/src/FGFDMExec.h @@ -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) {} }; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FGJSBBase.h b/src/FGJSBBase.h index 173ca34a5..69fbb0014 100644 --- a/src/FGJSBBase.h +++ b/src/FGJSBBase.h @@ -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) {} }; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -269,7 +269,7 @@ 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 @@ -277,7 +277,7 @@ class FGJSBBase { 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 @@ -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 @@ -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 valuemax?(max):(value)); } - + static constexpr double sign(double num) {return num>=0.0?1.0:-1.0;} static double GaussianRandomNumber(void); diff --git a/src/initialization/FGInitialCondition.cpp b/src/initialization/FGInitialCondition.cpp index af4ed2069..d265f0a32 100644 --- a/src/initialization/FGInitialCondition.cpp +++ b/src/initialization/FGInitialCondition.cpp @@ -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; @@ -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) { diff --git a/src/input_output/FGScript.cpp b/src/input_output/FGScript.cpp index b7a6385fd..0d664bd69 100644 --- a/src/input_output/FGScript.cpp +++ b/src/input_output/FGScript.cpp @@ -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)"; @@ -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)"; diff --git a/src/math/FGMatrix33.h b/src/math/FGMatrix33.h index 57e8d2f75..4fea5c410 100644 --- a/src/math/FGMatrix33.h +++ b/src/math/FGMatrix33.h @@ -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} { } }; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/math/FGTable.h b/src/math/FGTable.h index 45e5a3941..3cff44a6e 100644 --- a/src/math/FGTable.h +++ b/src/math/FGTable.h @@ -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} { } }; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/models/FGAerodynamics.cpp b/src/models/FGAerodynamics.cpp index 303f01229..9deb2caa9 100644 --- a/src/models/FGAerodynamics.cpp +++ b/src/models/FGAerodynamics.cpp @@ -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 @@ -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()); } } @@ -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"); } @@ -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()); } } diff --git a/src/models/FGGasCell.cpp b/src/models/FGGasCell.cpp index e14a32914..8d21fac5d 100644 --- a/src/models/FGGasCell.cpp +++ b/src/models/FGGasCell.cpp @@ -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")) && @@ -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", @@ -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")) && @@ -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", diff --git a/src/models/FGLGear.cpp b/src/models/FGLGear.cpp index 8e08de39e..3bc8aa03e 100644 --- a/src/models/FGLGear.cpp +++ b/src/models/FGLGear.cpp @@ -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); diff --git a/src/models/FGMassBalance.cpp b/src/models/FGMassBalance.cpp index 58bf91757..bc30c6457 100644 --- a/src/models/FGMassBalance.cpp +++ b/src/models/FGMassBalance.cpp @@ -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"); diff --git a/src/models/FGPropagate.cpp b/src/models/FGPropagate.cpp index b3932d6a2..452b61801 100644 --- a/src/models/FGPropagate.cpp +++ b/src/models/FGPropagate.cpp @@ -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()); } } } diff --git a/src/models/flight_control/FGKinemat.cpp b/src/models/flight_control/FGKinemat.cpp index c15dc661e..2140cfda1 100644 --- a/src/models/flight_control/FGKinemat.cpp +++ b/src/models/flight_control/FGKinemat.cpp @@ -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()); diff --git a/src/models/propulsion/FGBrushLessDCMotor.cpp b/src/models/propulsion/FGBrushLessDCMotor.cpp index 3ce5baeb4..53f71687f 100644 --- a/src/models/propulsion/FGBrushLessDCMotor.cpp +++ b/src/models/propulsion/FGBrushLessDCMotor.cpp @@ -74,7 +74,7 @@ FGBrushLessDCMotor::FGBrushLessDCMotor(FGFDMExec* exec, Element* el, int engine_ else { cerr << el->ReadFrom() << " is a mandatory parameter" << endl; - throw JSBBaseException("Missing parameter"); + throw BaseException("Missing parameter"); } if (el->FindElement("velocityconstant")) @@ -82,7 +82,7 @@ FGBrushLessDCMotor::FGBrushLessDCMotor(FGFDMExec* exec, Element* el, int engine_ else { cerr << el->ReadFrom() << " is a mandatory parameter" << endl; - throw JSBBaseException("Missing parameter"); + throw BaseException("Missing parameter"); } if (el->FindElement("coilresistance")) @@ -90,14 +90,14 @@ FGBrushLessDCMotor::FGBrushLessDCMotor(FGFDMExec* exec, Element* el, int engine_ else { cerr << el->ReadFrom() << " 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() << " is a mandatory parameter" << endl; - throw JSBBaseException("Missing parameter"); + throw BaseException("Missing parameter"); } double MaxCurrent = MaxVolts / CoilResistance + ZeroTorqueCurrent; diff --git a/src/models/propulsion/FGForce.cpp b/src/models/propulsion/FGForce.cpp index e6aa0a8a8..33e2f5e70 100644 --- a/src/models/propulsion/FGForce.cpp +++ b/src/models/propulsion/FGForce.cpp @@ -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); } } } diff --git a/src/models/propulsion/FGNozzle.cpp b/src/models/propulsion/FGNozzle.cpp index 84391113d..976533960 100644 --- a/src/models/propulsion/FGNozzle.cpp +++ b/src/models/propulsion/FGNozzle.cpp @@ -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; diff --git a/src/models/propulsion/FGTank.cpp b/src/models/propulsion/FGTank.cpp index d9a01332d..adfc1d76b 100644 --- a/src/models/propulsion/FGTank.cpp +++ b/src/models/propulsion/FGTank.cpp @@ -197,7 +197,7 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number) if (Radius <= InnerRadius) { const string s("The bore diameter should be smaller than the total grain diameter!"); cerr << element_Grain->ReadFrom() << endl << s << endl; - throw JSBBaseException(s); + throw BaseException(s); } Volume = M_PI * Length * (Radius*Radius - InnerRadius*InnerRadius); // cubic inches break; @@ -211,7 +211,7 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number) { const string s("Unknown grain type found in this rocket engine definition."); cerr << el->ReadFrom() << endl << s << endl; - throw JSBBaseException(s); + throw BaseException(s); } } Density = (Capacity*lbtoslug)/Volume; // slugs/in^3 @@ -379,7 +379,7 @@ void FGTank::CalculateInertias(void) } else { const string s(" Solid propellant grain density is zero!"); cerr << endl << s << endl; - throw JSBBaseException(s); + throw BaseException(s); } switch (grainType) { @@ -405,7 +405,7 @@ void FGTank::CalculateInertias(void) { const string s("Unknown grain type found."); cerr << s << endl; - throw JSBBaseException(s); + throw BaseException(s); } } diff --git a/src/simgear/xml/easyxml.cxx b/src/simgear/xml/easyxml.cxx index c7c4c8c72..a6bffa005 100644 --- a/src/simgear/xml/easyxml.cxx +++ b/src/simgear/xml/easyxml.cxx @@ -271,7 +271,7 @@ void readXML (istream &input, XMLVisitor &visitor, const string &path) visitor.setParser(0); XML_ParserFree(parser); cerr << endl << s.str() << endl; - throw JSBSim::JSBBaseException(s.str()); + throw JSBSim::BaseException(s.str()); } input.read(buf,16384); @@ -282,7 +282,7 @@ void readXML (istream &input, XMLVisitor &visitor, const string &path) cerr << endl << s.str() << endl; visitor.setParser(0); XML_ParserFree(parser); - throw JSBSim::JSBBaseException(s.str()); + throw JSBSim::BaseException(s.str()); } } @@ -295,7 +295,7 @@ void readXML (istream &input, XMLVisitor &visitor, const string &path) cerr << endl << s.str() << endl; visitor.setParser(0); XML_ParserFree(parser); - throw JSBSim::JSBBaseException(s.str()); + throw JSBSim::BaseException(s.str()); } visitor.setParser(0);