• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FC_THROW_EXCEPTION函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FC_THROW_EXCEPTION函数的典型用法代码示例。如果您正苦于以下问题:C++ FC_THROW_EXCEPTION函数的具体用法?C++ FC_THROW_EXCEPTION怎么用?C++ FC_THROW_EXCEPTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FC_THROW_EXCEPTION函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: variant_from_stream

  variant variant_from_stream( T& in, uint32_t max_depth )
  {
     if( max_depth == 0 )
         FC_THROW_EXCEPTION( parse_error_exception, "Too many nested items in JSON input!" );
     skip_white_space(in);
     signed char c = in.peek();
     switch( c )
     {
        case '"':
           return stringFromStream( in );
        case '{':
           return objectFromStream<T, parser_type>( in, max_depth - 1 );
        case '[':
           return arrayFromStream<T, parser_type>( in, max_depth - 1 );
        case '-':
        case '.':
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
           return number_from_stream<T, parser_type>( in );
        // null, true, false, or 'warning' / string
        case 'n':
        case 't':
        case 'f':
           return token_from_stream( in );
        case 0x04: // ^D end of transmission
        case EOF:
           FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
        case 0:
           if( parser_type == fc::json::broken_nul_parser )
              return variant();
           FALLTHROUGH
        default:
           FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"",
                               ("c", c)("s", stringFromToken(in)) );
     }
 }
开发者ID:bitshares,项目名称:fc,代码行数:44,代码来源:json.cpp


示例2: group

//    public_key public_key::mult( const fc::sha256& digest ) const
//    {
//        // get point from this public key
//        const EC_POINT* master_pub   = EC_KEY_get0_public_key( my->_key );
//        ec_group group(EC_GROUP_new_by_curve_name(NID_secp256k1));
//
//        ssl_bignum z;
//        BN_bin2bn((unsigned char*)&digest, sizeof(digest), z);
//
//        // multiply by digest
//        ssl_bignum one;
//        BN_one(one);
//        bn_ctx ctx(BN_CTX_new());
//
//        ec_point result(EC_POINT_new(group));
//        EC_POINT_mul(group, result, z, master_pub, one, ctx);
//
//        public_key rtn;
//        rtn.my->_key = EC_KEY_new_by_curve_name( NID_secp256k1 );
//        EC_KEY_set_public_key(rtn.my->_key,result);
//
//        return rtn;
//    }
    public_key public_key::add( const fc::sha256& digest )const
    {
      try {
        ec_group group(EC_GROUP_new_by_curve_name(NID_secp256k1));
        bn_ctx ctx(BN_CTX_new());

        fc::bigint digest_bi( (char*)&digest, sizeof(digest) );

        ssl_bignum order;
        EC_GROUP_get_order(group, order, ctx);
        if( digest_bi > fc::bigint(order) )
        {
          FC_THROW_EXCEPTION( exception, "digest > group order" );
        }


        public_key digest_key = private_key::regenerate(digest).get_public_key();
        const EC_POINT* digest_point   = EC_KEY_get0_public_key( digest_key.my->_key );

        // get point from this public key
        const EC_POINT* master_pub   = EC_KEY_get0_public_key( my->_key );

//        ssl_bignum z;
//        BN_bin2bn((unsigned char*)&digest, sizeof(digest), z);

        // multiply by digest
//        ssl_bignum one;
//        BN_one(one);

        ec_point result(EC_POINT_new(group));
        EC_POINT_add(group, result, digest_point, master_pub, ctx);

        if (EC_POINT_is_at_infinity(group, result))
        {
          FC_THROW_EXCEPTION( exception, "point at  infinity" );
        }


        public_key rtn;
        rtn.my->_key = EC_KEY_new_by_curve_name( NID_secp256k1 );
        EC_KEY_set_public_key(rtn.my->_key,result);
        return rtn;
      } FC_RETHROW_EXCEPTIONS( debug, "digest: ${digest}", ("digest",digest) );
    }
开发者ID:techsharesteam,项目名称:techshares,代码行数:67,代码来源:elliptic_impl_pub.cpp


示例3: handle_block

      /**
       * @brief allows the application to validate an item prior to broadcasting to peers.
       *
       * @param sync_mode true if the message was fetched through the sync process, false during normal operation
       * @returns true if this message caused the blockchain to switch forks, false if it did not
       *
       * @throws exception if error validating the item, otherwise the item is safe to broadcast on.
       */
      virtual bool handle_block(const graphene::net::block_message& blk_msg, bool sync_mode,
                                std::vector<fc::uint160_t>& contained_transaction_message_ids) override
      { try {

         auto latency = graphene::time::now() - blk_msg.block.timestamp;
         if (!sync_mode || blk_msg.block.block_num() % 10000 == 0)
         {
            const auto& witness = blk_msg.block.witness(*_chain_db);
            const auto& witness_account = witness.witness_account(*_chain_db);
            auto last_irr = _chain_db->get_dynamic_global_properties().last_irreversible_block_num;
            ilog("Got block: #${n} time: ${t} latency: ${l} ms from: ${w}  irreversible: ${i} (-${d})", 
                 ("t",blk_msg.block.timestamp)
                 ("n", blk_msg.block.block_num())
                 ("l", (latency.count()/1000))
                 ("w",witness_account.name)
                 ("i",last_irr)("d",blk_msg.block.block_num()-last_irr) );
         }

         try {
            // TODO: in the case where this block is valid but on a fork that's too old for us to switch to,
            // you can help the network code out by throwing a block_older_than_undo_history exception.
            // when the net code sees that, it will stop trying to push blocks from that chain, but
            // leave that peer connected so that they can get sync blocks from us
            bool result = _chain_db->push_block(blk_msg.block, (_is_block_producer | _force_validate) ? database::skip_nothing : database::skip_transaction_signatures);

            // the block was accepted, so we now know all of the transactions contained in the block
            if (!sync_mode)
            {
               // if we're not in sync mode, there's a chance we will be seeing some transactions
               // included in blocks before we see the free-floating transaction itself.  If that
               // happens, there's no reason to fetch the transactions, so  construct a list of the
               // transaction message ids we no longer need.
               // during sync, it is unlikely that we'll see any old
               for (const processed_transaction& transaction : blk_msg.block.transactions)
               {
                  graphene::net::trx_message transaction_message(transaction);
                  contained_transaction_message_ids.push_back(graphene::net::message(transaction_message).id());
               }
            }

            return result;
         } catch ( const graphene::chain::unlinkable_block_exception& e ) {
            // translate to a graphene::net exception
            elog("Error when pushing block:\n${e}", ("e", e.to_detail_string()));
            FC_THROW_EXCEPTION(graphene::net::unlinkable_block_exception, "Error when pushing block:\n${e}", ("e", e.to_detail_string()));
         } catch( const fc::exception& e ) {
            elog("Error when pushing block:\n${e}", ("e", e.to_detail_string()));
            throw;
         }

         if( !_is_finished_syncing && !sync_mode )
         {
            _is_finished_syncing = true;
            _self->syncing_finished();
         }
      } FC_CAPTURE_AND_RETHROW( (blk_msg)(sync_mode) ) }
开发者ID:unionsharesteam,项目名称:unionshares,代码行数:64,代码来源:application.cpp


示例4: remove

        void remove( const Key& k )
        {
          try
          {
             FC_ASSERT( _db != nullptr );

             std::vector<char> kslice = fc::raw::pack( k );
             ldb::Slice ks( kslice.data(), kslice.size() );
             auto status = _db->Delete( ldb::WriteOptions(), ks );
             if( status.IsNotFound() )
             {
               FC_THROW_EXCEPTION( key_not_found_exception, "unable to find key ${key}", ("key",k) );
             }
             if( !status.ok() )
             {
                 FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", status.ToString() ) );
             }
          } FC_RETHROW_EXCEPTIONS( warn, "error removing ${key}", ("key",k) );
        }
开发者ID:Coinfo,项目名称:bitshares_toolkit,代码行数:19,代码来源:level_map.hpp


示例5: add

 static void add( fc::sha256::encoder &hasher, std::string const &data )
 {
     if( data.size() < 253 ) {
         char len = data.size();
         hasher.write( &len, sizeof(len) );
     } else {
         FC_THROW_EXCEPTION( fc::invalid_arg_exception, "String '" + data + "' too long" );
     }
     hasher.write( data.c_str(), data.size() );
 }
开发者ID:NewportHighlander,项目名称:PTS,代码行数:10,代码来源:pts_address.cpp


示例6: FC_ASSERT

 void private_key::sign( const sha1& digest, array<char,2048/8>& sig )const
 {
    FC_ASSERT( (size_t(RSA_size(my->rsa)) <= sizeof(sig)), "Invalid RSA size" ); 
    uint32_t slen = 0;
    if( 1 != RSA_sign( NID_sha1, (uint8_t*)&digest,
                       20, (unsigned char*)&sig, &slen, my->rsa ) )
    {
        FC_THROW_EXCEPTION( exception, "rsa sign failed with ${message}", ("message",fc::string(ERR_error_string( ERR_get_error(),NULL))) );
    }
 }
开发者ID:FollowMyVote,项目名称:fc,代码行数:10,代码来源:pke.cpp


示例7: if

void client_impl::debug_advance_time(int32_t delta_time, const std::string& unit /* = "seconds" */)
{
   if (unit == "blocks")
      delta_time *= BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC;
   else if (unit == "rounds")
      delta_time *= BTS_BLOCKCHAIN_NUM_DELEGATES * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC;
   else if (unit != "seconds")
      FC_THROW_EXCEPTION(fc::invalid_arg_exception, "unit must be \"seconds\", \"blocks\", or \"rounds\", was: \"${unit}\"", ("unit", unit));
   bts::blockchain::advance_time(delta_time);
}
开发者ID:NewportHighlander,项目名称:PTS,代码行数:10,代码来源:debug_api.cpp


示例8: import_electrum_wallet

 std::vector<fc::ecc::private_key> import_electrum_wallet( const fc::path& wallet_dat, const std::string& passphrase )
 { try {
     std::vector<fc::ecc::private_key> keys;
     electrumwallet wallet( wallet_dat.to_native_ansi_path());
     if( !wallet.ok() ) FC_THROW_EXCEPTION( exception, "invalid electrum wallet");
     wallet.derivekeys( passphrase );
     return wallet.keys();
   }
   FC_RETHROW_EXCEPTIONS( warn, "" )
 }
开发者ID:BrownBear2,项目名称:BitShares,代码行数:10,代码来源:electrum_wallet.cpp


示例9: null_terminated_ptr_impl

/**
 * class to represent an in-wasm-memory char array that must be null terminated
 */
inline null_terminated_ptr null_terminated_ptr_impl(interpreter_interface* interface, uint32_t ptr)
{
   char *value = interface->get_validated_pointer(ptr, 1);
   const char* p = value;
   const char* const top_of_memory = interface->memory.data + interface->current_memory_size;
   while(p < top_of_memory)
      if(*p++ == '\0')
         return null_terminated_ptr(value);

   FC_THROW_EXCEPTION(wasm_execution_error, "unterminated string");
}
开发者ID:milk57618,项目名称:eos,代码行数:14,代码来源:binaryen.hpp


示例10: begin

        iterator begin() 
        { try {
           iterator itr( _db->NewIterator( ldb::ReadOptions() ) );
           itr._it->SeekToFirst();

           if( itr._it->status().IsNotFound() )
           {
             FC_THROW_EXCEPTION( key_not_found_exception, "" );
           }
           if( !itr._it->status().ok() )
           {
               FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", itr._it->status().ToString() ) );
           }

           if( itr.valid() )
           {
              return itr;
           }
           return iterator();
        } FC_RETHROW_EXCEPTIONS( warn, "error seeking to first" ) }
开发者ID:BrownBear2,项目名称:BitShares,代码行数:20,代码来源:level_map.hpp


示例11: memcpy

   pts_address::pts_address( const std::string& base58str )
   {
      std::vector<char> v = fc::from_base58( fc::string(base58str) );
      if( v.size() )
         memcpy( addr.data, v.data(), std::min<size_t>( v.size(), sizeof(addr) ) );

      if( !is_valid() )
      {
         FC_THROW_EXCEPTION( exception, "invalid pts_address ${a}", ("a", base58str) );  
      }
   }
开发者ID:NimroDeer,项目名称:BitShares,代码行数:11,代码来源:pts_address.cpp


示例12: fetch

 Value fetch( const Key& key )
 {
   try {
      ldb::Slice key_slice( (char*)&key, sizeof(key) );
      std::string value;
      auto status = _db->Get( ldb::ReadOptions(), key_slice, &value );
      if( status.IsNotFound() )
      {
        FC_THROW_EXCEPTION( key_not_found_exception, "unable to find key ${key}", ("key",key) );
      }
      if( !status.ok() )
      {
          FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", status.ToString() ) );
      }
      fc::datastream<const char*> datastream(value.c_str(), value.size());
      Value tmp;
      fc::raw::unpack(datastream, tmp);
      return tmp;
   } FC_RETHROW_EXCEPTIONS( warn, "error fetching key ${key}", ("key",key) );
 }
开发者ID:Doken-Tokuyama,项目名称:BitShares,代码行数:20,代码来源:level_pod_map.hpp


示例13: fetch

        Value fetch( const Key& key )
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           ldb::Slice key_slice( (char*)&key, sizeof(key) );
           std::string value;
           auto status = _db->Get( _read_options, key_slice, &value );
           if( status.IsNotFound() )
           {
             FC_THROW_EXCEPTION( fc::key_not_found_exception, "unable to find key ${key}", ("key",key) );
           }
           if( !status.ok() )
           {
               FC_THROW_EXCEPTION( level_pod_map_failure, "database error: ${msg}", ("msg", status.ToString() ) );
           }
           fc::datastream<const char*> datastream(value.c_str(), value.size());
           Value tmp;
           fc::raw::unpack(datastream, tmp);
           return tmp;
        } FC_RETHROW_EXCEPTIONS( warn, "error fetching key ${key}", ("key",key) ); }
开发者ID:ElleryHao,项目名称:Goopal,代码行数:20,代码来源:LevelPodMap.hpp


示例14: fetch

        Value fetch( const Key& k )
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           std::vector<char> kslice = fc::raw::pack( k );
           ldb::Slice ks( kslice.data(), kslice.size() );
           std::string value;
           auto status = _db->Get( ldb::ReadOptions(), ks, &value );
           if( status.IsNotFound() )
           {
             FC_THROW_EXCEPTION( fc::key_not_found_exception, "unable to find key ${key}", ("key",k) );
           }
           if( !status.ok() )
           {
               FC_THROW_EXCEPTION( db_exception, "database error: ${msg}", ("msg", status.ToString() ) );
           }
           fc::datastream<const char*> ds(value.c_str(), value.size());
           Value tmp;
           fc::raw::unpack(ds, tmp);
           return tmp;
        } FC_RETHROW_EXCEPTIONS( warn, "error fetching key ${key}", ("key",k) ); }
开发者ID:andrewisplinghoff,项目名称:bitsharesx,代码行数:21,代码来源:level_map.hpp


示例15: FC_ASSERT

 asset& asset::operator -= ( const asset& o )
 {
    FC_ASSERT( asset_id == o.asset_id );
    auto old = *this;;
    amount -= o.amount;
    if( amount > old.amount ) 
    {
       FC_THROW_EXCEPTION( addition_underthrow, "asset addition underflow  ${a} - ${b} = ${c}", 
                           ("a", old)("b",o)("c",*this) );
    }
    return *this;
 }
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:12,代码来源:asset.cpp


示例16: parseInt

 fc::variant parseInt( const std::string& token, size_t start )
 {
     static const CharValueTable ctbl;
     static const uint64_t INT64_MAX_PLUS_ONE = static_cast<uint64_t>(INT64_MAX) + 1;
     
     size_t i = start, n = token.length();
     if( i >= n )
         FC_THROW_EXCEPTION( parse_error_exception, "zero-length integer" );
     
     uint64_t val = 0;
     uint64_t maxb4mul = UINT64_MAX / base;
     
     while(true)
     {
         char c = token[i];
         uint8_t vc = ctbl[c];
         if( vc == 0xFF )
             FC_THROW_EXCEPTION( parse_error_exception, "illegal character {c} in integer of base {b}", ("c", c)("b", base) );
         if( val > maxb4mul )
             FC_THROW_EXCEPTION( parse_error_exception, "integer literal overflow" );
         val *= base;
         uint64_t newval = val + vc;
         if( newval < val )
             FC_THROW_EXCEPTION( parse_error_exception, "integer literal overflow" );
         val = newval;
         i++;
         if( i >= n )
             break;
     }
     if( token[0] == '-' )
     {
         if( val > INT64_MAX_PLUS_ONE )
             FC_THROW_EXCEPTION( parse_error_exception, "negative integer literal overflow" );
         // special cased to avoid trying to compute -INT64_MIN which is probably undefined or something
         if( val == INT64_MAX_PLUS_ONE )
             return fc::variant( INT64_MIN );
         return fc::variant( -static_cast<int64_t>(val) );
     }
     return fc::variant( val );
 }
开发者ID:bitshares,项目名称:fc,代码行数:40,代码来源:json_relaxed.hpp


示例17: sizeof

block_id_type block_database::fetch_block_id( uint32_t block_num )const
{
   index_entry e;
   auto index_pos = sizeof(e)*block_num;
   _block_num_to_pos.seekg( 0, _block_num_to_pos.end );
   if ( _block_num_to_pos.tellg() <= index_pos )
      FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block number ${block_num} not contained in block database", ("block_num", block_num));

   _block_num_to_pos.seekg( index_pos );
   _block_num_to_pos.read( (char*)&e, sizeof(e) );

   return e.block_id;
}
开发者ID:todasun,项目名称:graphene,代码行数:13,代码来源:block_database.cpp


示例18: begin

        iterator begin()
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           iterator itr( _db->NewIterator( _iter_options ) );
           itr._it->SeekToFirst();

           if( itr._it->status().IsNotFound() )
           {
             FC_THROW_EXCEPTION( fc::key_not_found_exception, "" );
           }
           if( !itr._it->status().ok() )
           {
               FC_THROW_EXCEPTION( level_pod_map_failure, "database error: ${msg}", ("msg", itr._it->status().ToString() ) );
           }

           if( itr.valid() )
           {
              return itr;
           }
           return iterator();
        } FC_RETHROW_EXCEPTIONS( warn, "error seeking to first" ) }
开发者ID:ElleryHao,项目名称:Goopal,代码行数:22,代码来源:LevelPodMap.hpp


示例19: handle_message

        /* ===================================================== */   
        void handle_message( const connection_ptr& con, const message& m )
        { 
          try {
           chan_data& cdat = get_channel_data(con);
 
           ilog( "${msg_type}", ("msg_type", (bitname::message_type)m.msg_type ) );
           
           switch( (bitname::message_type)m.msg_type )
           {
               case name_inv_msg:
                 handle_name_inv( con, cdat, m.as<name_inv_message>() );
                 break;
               case block_inv_msg:
                 handle_block_inv( con, cdat, m.as<block_inv_message>() );
                 break;
               case get_name_inv_msg:
                 handle_get_name_inv( con, cdat, m.as<get_name_inv_message>() );
                 break;
               case get_headers_msg:
                 handle_get_headers( con, cdat, m.as<get_headers_message>() );
                 break;
               case get_block_msg:
                 handle_get_block( con, cdat, m.as<get_block_message>() );
                 break;
               case get_block_index_msg:
                 handle_get_block_index( con, cdat, m.as<get_block_index_message>() );
                 break;
               case get_name_header_msg:
                 handle_get_name( con, cdat, m.as<get_name_header_message>() );
                 break;
               case name_header_msg:
                 handle_name( con, cdat, m.as<name_header_message>() );
                 break;
               case block_index_msg:
                 handle_block_index( con, cdat, m.as<block_index_message>() );
                 break;
               case block_msg:
                 handle_block( con, cdat, m.as<block_message>() );
                 break;
               case headers_msg:
                 handle_headers( con, cdat, m.as<headers_message>() );
                 break;
               default:
                 FC_THROW_EXCEPTION( exception, "unknown bitname message type ${msg_type}", ("msg_type", m.msg_type ) );
           }
          } 
          catch ( fc::exception& e )
          {
            wlog( "${e}  ${from}", ("e",e.to_detail_string())("from",con->remote_endpoint()) );
          }
        }  // handle_message
开发者ID:1manStartup,项目名称:BitShares,代码行数:52,代码来源:bitname_channel.cpp


示例20: electrumwallet

      electrumwallet( std::string path ):encryption(false),seed_version(""),masterkey("")
      {
         std::ifstream in(path, std::ios_base::in);
         std::string storage;
         in.unsetf( std::ios::skipws );
         std::copy( std::istream_iterator<char>(in),
                    std::istream_iterator<char>(),
                    std::back_inserter(storage) );

         bts::parser<std::string::const_iterator> grammar;
         bts::python_dict_type_t dict;

         std::string::const_iterator iter = storage.begin();
         std::string::const_iterator end = storage.end();
         bool r = phrase_parse( iter, end, grammar, ascii::space, dict );

         if( r && iter == end )
         {
            for( auto &item : dict.items )
            {
               boost::to_lower( item.first );
               if( item.first == "use_encryption" )
               {
                  auto useenc = boost::get<std::string>( item.second );
                  boost::to_lower(useenc);
                  if ( useenc == "true" )
                     encryption = true;
               }
               else if( item.first == "seed_version" )
               {
                  seed_version = boost::get<std::string>( item.second );
               }
               else if( item.first == "seed" )
               {
                  seed = boost::get<std::string>( item.second );
               }
               else if( item.first == "master_public_key" )
               {
                  masterkey = boost::get<std::string>( item.second );
               }
               else if( item.first == "accounts" )
               {
                  accounts.items = boost::get<bts::python_dict_type_t>( item.second ).items;
               }
            }
         }
         else
         {
            FC_THROW_EXCEPTION( exception, "failed to parse electrum wallet" );
         }
      }
开发者ID:BrownBear2,项目名称:BitShares,代码行数:51,代码来源:electrum_wallet.cpp



注:本文中的FC_THROW_EXCEPTION函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FColor函数代码示例发布时间:2022-05-30
下一篇:
C++ FC_RETHROW_EXCEPTIONS函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap