FC Updates from BitShares and myself #21
5 changed files with 12 additions and 26 deletions
|
|
@ -106,7 +106,7 @@ namespace fc
|
|||
*
|
||||
* @note does not return.
|
||||
*/
|
||||
virtual NO_RETURN void dynamic_rethrow_exception()const;
|
||||
[[noreturn]] virtual void dynamic_rethrow_exception()const;
|
||||
|
||||
/**
|
||||
* This is equivalent to:
|
||||
|
|
@ -155,7 +155,7 @@ namespace fc
|
|||
|
||||
std::exception_ptr get_inner_exception()const;
|
||||
|
||||
virtual NO_RETURN void dynamic_rethrow_exception()const;
|
||||
[[noreturn]] virtual void dynamic_rethrow_exception()const;
|
||||
virtual std::shared_ptr<exception> dynamic_copy_exception()const;
|
||||
private:
|
||||
std::exception_ptr _inner;
|
||||
|
|
@ -179,13 +179,13 @@ namespace fc
|
|||
public:
|
||||
struct base_exception_builder
|
||||
{
|
||||
virtual NO_RETURN void rethrow( const exception& e )const = 0;
|
||||
[[noreturn]] virtual void rethrow( const exception& e )const = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct exception_builder : public base_exception_builder
|
||||
{
|
||||
virtual NO_RETURN void rethrow( const exception& e )const override
|
||||
[[noreturn]] virtual void rethrow( const exception& e )const override
|
||||
{
|
||||
throw T( e );
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ namespace fc
|
|||
_registered_exceptions[T::code_value] = &builder;
|
||||
}
|
||||
|
||||
void NO_RETURN rethrow( const exception& e )const;
|
||||
[[noreturn]] void rethrow( const exception& e )const;
|
||||
|
||||
static exception_factory& instance()
|
||||
{
|
||||
|
|
@ -243,7 +243,7 @@ namespace fc
|
|||
explicit TYPE();\
|
||||
\
|
||||
virtual std::shared_ptr<fc::exception> dynamic_copy_exception()const;\
|
||||
virtual NO_RETURN void dynamic_rethrow_exception()const; \
|
||||
[[noreturn]] virtual void dynamic_rethrow_exception()const; \
|
||||
};
|
||||
|
||||
#define FC_IMPLEMENT_DERIVED_EXCEPTION( TYPE, BASE, CODE, WHAT ) \
|
||||
|
|
@ -269,7 +269,7 @@ namespace fc
|
|||
{ \
|
||||
return std::make_shared<TYPE>( *this ); \
|
||||
} \
|
||||
NO_RETURN void TYPE::dynamic_rethrow_exception()const \
|
||||
[[noreturn]] void TYPE::dynamic_rethrow_exception()const \
|
||||
{ \
|
||||
if( code() == CODE ) throw *this;\
|
||||
else fc::exception::dynamic_rethrow_exception(); \
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
#include <fc/utility.hpp>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -7,7 +6,7 @@ namespace fc {
|
|||
|
||||
namespace detail
|
||||
{
|
||||
NO_RETURN void throw_datastream_range_error( const char* file, size_t len, int64_t over );
|
||||
[[noreturn]] void throw_datastream_range_error( const char* file, size_t len, int64_t over );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,19 +2,6 @@
|
|||
#include <stdint.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4482) // nonstandard extension used enum Name::Val, standard in C++11
|
||||
#define NO_RETURN __declspec(noreturn)
|
||||
#else
|
||||
#define NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
|
||||
|
||||
//namespace std {
|
||||
// typedef decltype(sizeof(int)) size_t;
|
||||
// typedef decltype(nullptr) nullptr_t;
|
||||
//}
|
||||
|
||||
namespace fc {
|
||||
using std::size_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ namespace fc
|
|||
|
||||
std::exception_ptr unhandled_exception::get_inner_exception()const { return _inner; }
|
||||
|
||||
NO_RETURN void unhandled_exception::dynamic_rethrow_exception()const
|
||||
[[noreturn]] void unhandled_exception::dynamic_rethrow_exception()const
|
||||
{
|
||||
if( !(_inner == std::exception_ptr()) ) std::rethrow_exception( _inner );
|
||||
else { fc::exception::dynamic_rethrow_exception(); }
|
||||
|
|
@ -217,7 +217,7 @@ namespace fc
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
void NO_RETURN exception_factory::rethrow( const exception& e )const
|
||||
[[noreturn]] void exception_factory::rethrow( const exception& e )const
|
||||
{
|
||||
auto itr = _registered_exceptions.find( e.code() );
|
||||
if( itr != _registered_exceptions.end() )
|
||||
|
|
@ -229,7 +229,7 @@ namespace fc
|
|||
* the error code. This is used to propagate exception types
|
||||
* across conversions to/from JSON
|
||||
*/
|
||||
NO_RETURN void exception::dynamic_rethrow_exception()const
|
||||
[[noreturn]] void exception::dynamic_rethrow_exception()const
|
||||
{
|
||||
exception_factory::instance().rethrow( *this );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <fc/io/datastream.hpp>
|
||||
#include <fc/exception/exception.hpp>
|
||||
|
||||
NO_RETURN void fc::detail::throw_datastream_range_error(char const* method, size_t len, int64_t over)
|
||||
[[noreturn]] void fc::detail::throw_datastream_range_error(char const* method, size_t len, int64_t over)
|
||||
{
|
||||
FC_THROW_EXCEPTION( out_of_range_exception, "${method} datastream of length ${len} over by ${over}", ("method",std::string(method))("len",len)("over",over) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue