Add-ons: move exceptions to their own translation unit
This commit is contained in:
parent
01f0f27c84
commit
d81599efd1
6 changed files with 126 additions and 51 deletions
|
@ -41,6 +41,7 @@
|
|||
#include "Addon.hxx"
|
||||
#include "AddonManager.hxx"
|
||||
#include "AddonVersion.hxx"
|
||||
#include "exceptions.hxx"
|
||||
|
||||
namespace strutils = simgear::strutils;
|
||||
|
||||
|
@ -54,24 +55,6 @@ namespace flightgear
|
|||
|
||||
static unique_ptr<AddonManager> staticInstance;
|
||||
|
||||
namespace addon_errors
|
||||
{
|
||||
// ***************************************************************************
|
||||
// * Base class for custom exceptions *
|
||||
// ***************************************************************************
|
||||
|
||||
// Prepending a prefix such as "Add-on error: " would be redundant given the
|
||||
// messages used below.
|
||||
error::error(const string& message, const string& origin)
|
||||
: sg_exception(message, origin)
|
||||
{ }
|
||||
|
||||
error::error(const char* message, const char* origin)
|
||||
: error(string(message), string(origin))
|
||||
{ }
|
||||
|
||||
} // of namespace addon_errors
|
||||
|
||||
// ***************************************************************************
|
||||
// * AddonManager *
|
||||
// ***************************************************************************
|
||||
|
|
|
@ -35,37 +35,6 @@
|
|||
namespace flightgear
|
||||
{
|
||||
|
||||
namespace addon_errors
|
||||
{
|
||||
// Custom exception classes
|
||||
class error : public sg_exception
|
||||
{
|
||||
public:
|
||||
explicit error(const std::string& message,
|
||||
const std::string& origin = std::string());
|
||||
explicit error(const char* message, const char* origin = nullptr);
|
||||
};
|
||||
|
||||
class error_loading_config_file : public error
|
||||
{ using error::error; /* inherit all constructors */ };
|
||||
|
||||
class no_metadata_file_found : public error
|
||||
{ using error::error; };
|
||||
|
||||
class error_loading_metadata_file : public error
|
||||
{ using error::error; };
|
||||
|
||||
class duplicate_registration_attempt : public error
|
||||
{ using error::error; };
|
||||
|
||||
class fg_version_too_old : public error
|
||||
{ using error::error; };
|
||||
|
||||
class fg_version_too_recent : public error
|
||||
{ using error::error; };
|
||||
|
||||
} // of namespace addon_errors
|
||||
|
||||
class AddonManager
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
include(FlightGearComponent)
|
||||
|
||||
set(SOURCES Addon.cxx AddonManager.cxx AddonVersion.cxx)
|
||||
set(HEADERS addon_fwd.hxx Addon.hxx AddonManager.hxx AddonVersion.hxx)
|
||||
set(SOURCES Addon.cxx
|
||||
AddonManager.cxx
|
||||
AddonVersion.cxx
|
||||
exceptions.cxx
|
||||
)
|
||||
|
||||
set(HEADERS addon_fwd.hxx
|
||||
Addon.hxx
|
||||
AddonManager.hxx
|
||||
AddonVersion.hxx
|
||||
exceptions.hxx
|
||||
)
|
||||
|
||||
flightgear_component(AddonManagement "${SOURCES}" "${HEADERS}")
|
||||
|
||||
|
|
49
src/Add-ons/exceptions.cxx
Normal file
49
src/Add-ons/exceptions.cxx
Normal file
|
@ -0,0 +1,49 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
//
|
||||
// exceptions.cxx --- Exception classes for the FlightGear add-on infrastructure
|
||||
// Copyright (C) 2017 Florent Rougon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include "exceptions.hxx"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
|
||||
namespace addon_errors
|
||||
{
|
||||
// ***************************************************************************
|
||||
// * Base class for custom exceptions *
|
||||
// ***************************************************************************
|
||||
|
||||
// Prepending a prefix such as "Add-on error: " would be redundant given the
|
||||
// messages used in, e.g., the Addon class code.
|
||||
error::error(const string& message, const string& origin)
|
||||
: sg_exception(message, origin)
|
||||
{ }
|
||||
|
||||
error::error(const char* message, const char* origin)
|
||||
: error(string(message), string(origin))
|
||||
{ }
|
||||
|
||||
} // of namespace addon_errors
|
||||
|
||||
} // of namespace flightgear
|
63
src/Add-ons/exceptions.hxx
Normal file
63
src/Add-ons/exceptions.hxx
Normal file
|
@ -0,0 +1,63 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
//
|
||||
// exceptions.hxx --- Exception classes for the FlightGear add-on infrastructure
|
||||
// Copyright (C) 2017 Florent Rougon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#ifndef FG_ADDON_EXCEPTIONS_HXX
|
||||
#define FG_ADDON_EXCEPTIONS_HXX
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
|
||||
namespace addon_errors
|
||||
{
|
||||
|
||||
class error : public sg_exception
|
||||
{
|
||||
public:
|
||||
explicit error(const std::string& message,
|
||||
const std::string& origin = std::string());
|
||||
explicit error(const char* message, const char* origin = nullptr);
|
||||
};
|
||||
|
||||
class error_loading_config_file : public error
|
||||
{ using error::error; /* inherit all constructors */ };
|
||||
|
||||
class no_metadata_file_found : public error
|
||||
{ using error::error; };
|
||||
|
||||
class error_loading_metadata_file : public error
|
||||
{ using error::error; };
|
||||
|
||||
class duplicate_registration_attempt : public error
|
||||
{ using error::error; };
|
||||
|
||||
class fg_version_too_old : public error
|
||||
{ using error::error; };
|
||||
|
||||
class fg_version_too_recent : public error
|
||||
{ using error::error; };
|
||||
|
||||
} // of namespace addon_errors
|
||||
|
||||
} // of namespace flightgear
|
||||
|
||||
#endif // of FG_ADDON_EXCEPTIONS_HXX
|
|
@ -10,6 +10,7 @@ set(sources
|
|||
Add-ons/Addon.cxx
|
||||
Add-ons/AddonManager.cxx
|
||||
Add-ons/AddonVersion.cxx
|
||||
Add-ons/exceptions.cxx
|
||||
Aircraft/controls.cxx
|
||||
Aircraft/FlightHistory.cxx
|
||||
Aircraft/flightrecorder.cxx
|
||||
|
|
Loading…
Reference in a new issue