#ifndef NAVLIB_ERROR_H_INCLUDED_
#define NAVLIB_ERROR_H_INCLUDED_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (c) 2014-2021 3Dconnexion.
*
* 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 3 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, see .
*/
/**
* @file navlib_error.h
* @brief defines the classes used for error reporting.
*/
#include
#include
#ifndef NOEXCEPT
#if defined(_MSC_VER) && _MSC_VER < 1800
#ifdef _NOEXCEPT
#define NOEXCEPT _NOEXCEPT
#else
#define NOEXCEPT
#endif
#else
#define NOEXCEPT noexcept
#endif
#endif
namespace std {
template <> struct is_error_code_enum<::navlib::navlib_errc::navlib_errc_t> : true_type {};
} // namespace std
namespace { // Anonymous namespace
///
/// Navigation library error category.
///
struct navlib_error_category : public std::error_category {
typedef std::error_category base_type;
public:
navlib_error_category() NOEXCEPT {
}
const char *name() const NOEXCEPT override {
return "navlib";
}
std::string message(int errorValue) const override {
namespace navlib_errc = navlib::navlib_errc;
switch (static_cast(errorValue)) {
case navlib_errc::property_not_found:
return "Cannot locate the requested navlib property.";
case navlib_errc::invalid_function:
return "The requested function is not valid.";
case navlib_errc::insufficient_buffer:
return "Insufficient buffer space.";
default:
return std::generic_category().message(errorValue);
}
}
};
///
/// Navigation library error category.
///
static const navlib_error_category navlib_category;
} // namespace
namespace navlib {
///
/// Makes a .
///
/// The Navigation library error.
/// A with the Navigation library category.
inline std::error_code make_error_code(navlib_errc::navlib_errc_t errc) {
std::error_code ec(static_cast(errc), navlib_category);
return ec;
}
} // namespace navlib
#endif /* NAVLIB_ERROR_H_INCLUDED_ */