Ejemplo n.º 1
0
 void NO_RETURN exception_factory::rethrow( const exception& e )const
 {
    auto itr = _registered_exceptions.find( e.code() );
    if( itr != _registered_exceptions.end() )
       itr->second->rethrow( e );
    throw e;
 }
Ejemplo n.º 2
0
   void to_variant( const exception& e, variant& v, uint32_t max_depth )
   {
      FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
      variant v_log;
      to_variant( e.get_log(), v_log, max_depth - 1 );
      mutable_variant_object tmp;
      tmp( "code", e.code() )
         ( "name", e.name() )
         ( "message", e.what() )
         ( "stack", v_log );
      v = variant( tmp, max_depth );

   }
Ejemplo n.º 3
0
#include "mbedcrypto/types.hpp"
#include "mbedtls/md.h"
#include <catch.hpp>
#include <cstring>

///////////////////////////////////////////////////////////////////////////////

TEST_CASE("mbedcrypto error / exception checkings", "[types][exception]") {
    using namespace mbedcrypto;

    SECTION("error codes") {
        exception ex1(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE, "not implemented");
        REQUIRE(ex1.code() == MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE);
        REQUIRE(std::strlen(ex1.what()) > 0);
        REQUIRE(ex1.error_string().size() > 0);

        exception ex2("error without error code");
        REQUIRE(ex2.code() == 0);
        REQUIRE(ex2.error_string().size() == 0);

        exception ex3(MBEDTLS_ERR_MD_BAD_INPUT_DATA);
        REQUIRE(ex3.code() != 0);
        REQUIRE(ex3.error_string().size() > 0);
        REQUIRE(ex3.error_string() == ex3.what()); // only error code
    }

    SECTION("throws") {
        try {
            mbedtls_md_context_t md;
            mbedtls_md_init(&md); // initialize items to nullptr
            // uninitialize (no md type): mbedcrypto_c_call must throw:
Ejemplo n.º 4
0
// =-=-=-=-=-=-=-
// public - constructor from exception
    error::error( const exception& _exc ) :
        status_(false),
        code_(_exc.code()),
        exception_(_exc) {
        } // cctor