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

C++ FC_RETHROW_EXCEPTIONS函数代码示例

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

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



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

示例1: FC_ASSERT

parameter_description_list api_generator::load_parameters(const fc::variants& json_parameter_descriptions)
{
  parameter_description_list parameters;
  for (const fc::variant& parameter_description_variant : json_parameter_descriptions)
  {
    fc::variant_object json_parameter_description = parameter_description_variant.get_object();
    parameter_description parameter;
    FC_ASSERT(json_parameter_description.contains("name"), "parameter is missing \"name\"");
    parameter.name = json_parameter_description["name"].as_string();
    try
    {
      FC_ASSERT(json_parameter_description.contains("description"), "parameter is missing \"description\"");
      parameter.description = json_parameter_description["description"].as_string();
      FC_ASSERT(json_parameter_description.contains("type"), "parameter is missing \"type\"");
      parameter.type = lookup_type_mapping(json_parameter_description["type"].as_string());
      if( json_parameter_description.contains( "prompt" ) )
         parameter.prompt = json_parameter_description["prompt"].as_bool();
      if (json_parameter_description.contains("default_value"))
        parameter.default_value = json_parameter_description["default_value"];
      if (json_parameter_description.contains("example"))
        parameter.example = json_parameter_description["example"];
    }
    FC_RETHROW_EXCEPTIONS(error, "error processing parameter ${name}", ("name", parameter.name));
    parameters.push_back(parameter);
  }
  return parameters;
}
开发者ID:InvictusInnovations,项目名称:keyhotee,代码行数:27,代码来源:bts_api_generator.cpp


示例2: parseEscape

   char parseEscape( T& in )
   {
      if( in.peek() == '\\' )
      {
         try {
            in.get();
            switch( in.peek() )
            {
               case 't':
                  in.get();
                  return '\t';
               case 'n':
                  in.get();
                  return '\n';
               case 'r':
                  in.get();
                  return '\r';
               case '\\':
                  in.get();
                  return '\\';
               default:
                  return in.get();
            }
         } FC_RETHROW_EXCEPTIONS( info, "Stream ended with '\\'" );
      }
	    FC_THROW_EXCEPTION( parse_error_exception, "Expected '\\'"  );
   }
开发者ID:bitshares,项目名称:fc,代码行数:27,代码来源:json.cpp


示例3: digest

void    signed_transaction::sign( const fc::ecc::private_key& k )
{
    try {
        sigs.insert( k.sign_compact( digest() ) );
    }
    FC_RETHROW_EXCEPTIONS( warn, "error signing transaction", ("trx", *this ) );
}
开发者ID:NimroDeer,项目名称:BitShares,代码行数:7,代码来源:transaction.cpp


示例4: close

void stcp_socket::close()
{
  try 
  {
    _sock.close();
  }FC_RETHROW_EXCEPTIONS( warn, "error closing stcp socket" );
}
开发者ID:0dayZh,项目名称:graphene,代码行数:7,代码来源:stcp_socket.cpp


示例5: FC_CAPTURE_AND_THROW

  /**
   *  A price will reorder the asset types such that the
   *  asset type with the lower enum value is always the
   *  denominator.  Therefore  bts/usd and  usd/bts will
   *  always result in a price measured in usd/bts because
   *  asset::bts <  asset::usd.
   */
  price operator / ( const asset& a, const asset& b )
  {
    try 
    {
        if( a.asset_id == b.asset_id )
           FC_CAPTURE_AND_THROW( asset_divide_by_self );

        price p;
        auto l = a; auto r = b;
        if( l.asset_id < r.asset_id ) { std::swap(l,r); }
        ilog( "${a} / ${b}", ("a",l)("b",r) );

        if( r.amount == 0 )
           FC_CAPTURE_AND_THROW( asset_divide_by_zero, (r) );

        p.base_asset_id = r.asset_id;
        p.quote_asset_id = l.asset_id;

        fc::bigint bl = l.amount;
        fc::bigint br = r.amount;
        fc::bigint result = (bl * fc::bigint(BTS_PRICE_PRECISION)) / br;

        p.ratio = result;
        return p;
    } FC_RETHROW_EXCEPTIONS( warn, "${a} / ${b}", ("a",a)("b",b) );
  }
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:33,代码来源:asset.cpp


示例6: arrayFromStream

   variants arrayFromStream( T& in )
   {
      variants ar;
      try
      {
        if( in.peek() != '[' )
           FC_THROW_EXCEPTION( parse_error_exception, "Expected '['" );
        in.get();
        skip_white_space(in);

        while( in.peek() != ']' )
        {
           if( in.peek() == ',' )
           {
              in.get();
              continue;
           }
           if( skip_white_space(in) ) continue;
           ar.push_back( variant_from_stream<T, parser_type>(in) );
           skip_white_space(in);
        }
        if( in.peek() != ']' )
           FC_THROW_EXCEPTION( parse_error_exception, "Expected ']' after parsing ${variant}",
                                    ("variant", ar) );

        in.get();
      } FC_RETHROW_EXCEPTIONS( warn, "Attempting to parse array ${array}",
                                         ("array", ar ) );
      return ar;
   }
开发者ID:Bitcoinsulting,项目名称:fc,代码行数:30,代码来源:json.cpp


示例7: arrayFromStreamBase

   variants arrayFromStreamBase( T& in, std::function<variant(T&)>& get_value  )
   {
      variants ar;
      try
      {
        if( in.peek() != '[' )
           FC_THROW_EXCEPTION( parse_error_exception, "Expected '['" );
        in.get();

        while( in.peek() != ']' )
        {
           if( in.peek() == ',' )
           {
              in.get();
              continue;
           }
           if( skip_white_space(in) ) continue;
           ar.push_back( get_value(in) );
        }
        if( in.peek() != ']' )
           FC_THROW_EXCEPTION( parse_error_exception, "Expected ']' after parsing ${variant}",
                                    ("variant", ar) );

        in.get();
      } FC_RETHROW_EXCEPTIONS( warn, "Attempting to parse array ${array}",
                                         ("array", ar ) );
      return ar;
   }
开发者ID:bitshares,项目名称:fc,代码行数:28,代码来源:json.cpp


示例8: ilog

  /**
   *  A price will reorder the asset types such that the
   *  asset type with the lower enum value is always the
   *  denominator.  Therefore  bts/usd and  usd/bts will
   *  always result in a price measured in usd/bts because
   *  asset::bts <  asset::usd.
   */
  price operator / ( const asset& a, const asset& b )
  {
    try 
    {
        ilog( "${a} / ${b}", ("a",a)("b",b) );
        price p;
        auto l = a; auto r = b;
        if( l.asset_id < r.asset_id ) { std::swap(l,r); }
        ilog( "${a} / ${b}", ("a",l)("b",r) );

        p.base_asset_id = r.asset_id;
        p.quote_asset_id = l.asset_id;

        //fc::uint128 bl(l.amount);
        //fc::uint128 bl(r.amount);

       // p.ratio = (bl* BTS_PRICE_PRECISION) / br;
        fc::bigint bl = l.amount;
        fc::bigint br = r.amount;
        fc::bigint result = (bl * fc::bigint(BTS_PRICE_PRECISION)) / br;

        p.ratio = result;
        return p;
    } FC_RETHROW_EXCEPTIONS( warn, "${a} / ${b}", ("a",a)("b",b) );
  }
开发者ID:Johnnychi,项目名称:bitshares_toolkit,代码行数:32,代码来源:asset.cpp


示例9: FC_RETHROW_EXCEPTIONS

 void tcp_socket::close() {
   try {
       if( is_open() )
       { 
         my->_sock.close();
       }
   } FC_RETHROW_EXCEPTIONS( warn, "error closing tcp socket" );
 }
开发者ID:BestSilent,项目名称:eos,代码行数:8,代码来源:tcp_socket.cpp


示例10: FC_ASSERT

 void tcp_server::accept( tcp_socket& s ) 
 {
   try
   {
     FC_ASSERT( my != nullptr );
     fc::asio::tcp::accept( my->_accept, s.my->_sock  ); 
   } FC_RETHROW_EXCEPTIONS( warn, "Unable to accept connection on socket." );
 }
开发者ID:DerKorb,项目名称:fc,代码行数:8,代码来源:tcp_socket.cpp


示例11: tokenFromStream

   std::string tokenFromStream( T& in )
   {
      fc::stringstream token;
      try
      {
         char c = in.peek();

         while( true )
         {
            switch( c = in.peek() )
            {
               case '\\':
                  token << parseEscape( in );
                  break;
               case '\t':
               case ' ':
               case ',':
               case ':':
               case '\0':
               case '\n':
               case '\x04':
                  in.get();
                  return token.str();
               case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
               case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
               case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
               case 'y': case 'z':
               case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H':
               case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P':
               case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
               case 'Y': case 'Z':
               case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
               case '8': case '9':
               case '_': case '-': case '.': case '+': case '/':
                  token << c;
                  in.get();
                  break;
               default:
                  return token.str();
            }
         }
         return token.str();
      }
      catch( const fc::eof_exception& eof )
      {
         return token.str();
      }
      catch (const std::ios_base::failure&)
      {
         return token.str();
      }

      FC_RETHROW_EXCEPTIONS( warn, "while parsing token '${token}'",
                                          ("token", token.str() ) );
   }
开发者ID:bitshares,项目名称:fc,代码行数:55,代码来源:json_relaxed.hpp


示例12: ba

  /**
   *  Assuming a.type is either the numerator.type or denominator.type in
   *  the price equation, return the number of the other asset type that
   *  could be exchanged at price p.
   *
   *  ie:  p = 3 usd/bts & a = 4 bts then result = 12 usd
   *  ie:  p = 3 usd/bts & a = 4 usd then result = 1.333 bts 
   */
  asset operator * ( const asset& a, const price& p )
  {
    try {
        if( a.asset_id == p.base_asset_id )
        {
            fc::bigint ba( a.amount ); // 64.64
            fc::bigint r( p.ratio ); // 64.64

            auto amnt = ba * r; //  128.128
            amnt /= BTS_PRICE_PRECISION; // 128.64 
            auto lg2 = amnt.log2();
            if( lg2 >= 128 )
            {
               FC_THROW_EXCEPTION( addition_overflow, "overflow ${a} * ${p}", ("a",a)("p",p) );
            }

            asset rtn;
            rtn.amount = amnt.to_int64();
            rtn.asset_id = p.quote_asset_id;

            ilog( "${a} * ${p} => ${rtn}", ("a", a)("p",p )("rtn",rtn) );
            return rtn;
        }
        else if( a.asset_id == p.quote_asset_id )
        {
            fc::bigint amt( a.amount ); // 64.64
            amt *= BTS_PRICE_PRECISION; //<<= 64;  // 64.128
            fc::bigint pri( p.ratio ); // 64.64

            auto result = amt / pri;  // 64.64
//            ilog( "amt: ${amt} / ${pri}", ("amt",string(amt))("pri",string(pri) ) );
 //           ilog( "${r}", ("r",string(result) ) );

            auto lg2 = result.log2();
            if( lg2 >= 128 )
            {
             //  wlog( "." );
               FC_THROW_EXCEPTION( addition_overflow, 
                                    "overflow ${a} / ${p} = ${r} lg2 = ${l}", 
                                    ("a",a)("p",p)("r", std::string(result)  )("l",lg2) );
            }
          //  result += 5000000000; // TODO: evaluate this rounding factor..
            asset r;
            r.amount    = result.to_int64();
            r.asset_id  = p.base_asset_id;
            ilog( "r.amount = ${r}", ("r",r.amount) );
            ilog( "${a} * ${p} => ${rtn}", ("a", a)("p",p )("rtn",r) );
            return r;
        }
        FC_THROW_EXCEPTION( asset_type_mismatch, "type mismatch multiplying asset ${a} by price ${p}", 
                                            ("a",a)("p",p) );
    } FC_RETHROW_EXCEPTIONS( warn, "type mismatch multiplying asset ${a} by price ${p}", 
                                        ("a",a)("p",p) );

  }
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:63,代码来源:asset.cpp


示例13: stringFromStream

   std::string stringFromStream( T& in )
   {
      try
      {
         char c = in.peek(), c2;

         switch( c )
         {
             case '\'':
                 if( strict )
                     FC_THROW_EXCEPTION( parse_error_exception, "expected: '\"' at beginning of string, got '\''" );
                 // falls through
             case '"':
                 return quoteStringFromStream<T, strict, true>( in );
             case 'r':
                 if( strict )
                     FC_THROW_EXCEPTION( parse_error_exception, "raw strings not supported in strict mode" );
             case 'R':
                 in.get();
                 c2 = in.peek();
                 switch( c2 )
                 {
                     case '"':
                     case '\'':
                         if( strict )
                             FC_THROW_EXCEPTION( parse_error_exception, "raw strings not supported in strict mode" );
                         return quoteStringFromStream<T, strict, false>( in );
                     default:
                         if( strict )
                             FC_THROW_EXCEPTION( parse_error_exception, "unquoted strings not supported in strict mode" );
                         return c+tokenFromStream( in );
                 }
                 break;
             case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
             case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
             case 'q':           case 's': case 't': case 'u': case 'v': case 'w': case 'x':
             case 'y': case 'z':
             case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H':
             case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P':
             case 'Q':           case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
             case 'Y': case 'Z':
             case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
             case '8': case '9':
             case '_': case '-': case '.': case '+': case '/':
                 if( strict )
                     FC_THROW_EXCEPTION( parse_error_exception, "unquoted strings not supported in strict mode" );
                 return tokenFromStream( in );
             default:
                 FC_THROW_EXCEPTION( parse_error_exception, "expected: string" );
         }

       } FC_RETHROW_EXCEPTIONS( warn, "while parsing string" );

       return {};
   }
开发者ID:bitshares,项目名称:fc,代码行数:55,代码来源:json_relaxed.hpp


示例14: remote_endpoint

 void connection::connect( const fc::ip::endpoint& ep )
 {
    try {
      // TODO: do we have to worry about multiple calls to connect?
      my->sock = std::make_shared<stcp_socket>();
      my->sock->connect_to(ep); 
      my->remote_ep = remote_endpoint();
      ilog( "    connected to ${ep}", ("ep", ep) );
      my->_read_loop_complete = fc::async( [=](){ my->read_loop(); } );
    } FC_RETHROW_EXCEPTIONS( warn, "error connecting to ${ep}", ("ep",ep) );
 }
开发者ID:NimroDeer,项目名称:BitShares,代码行数:11,代码来源:connection.cpp


示例15: ilog

/**
 *  Adds the owner to the required signature list
 *  Adds the balance to the trx balance sheet
 *
 *  TODO: this input is also valid if it is 1 year old and an output exists
 *        paying 95% of the balance back to the owner.
 *
 *  TODO: what if the source is an unvested market order... it means the
 *        proceeds of this trx are also 'unvested'.  Perhaps we will have to
 *        propagate the vested state along with the trx, if any inputs are
 *        sourced from an unvested trx, the new trx is also 'unvested' until
 *        the most receint input is fully vested.
 */
void trx_validation_state::validate_signature( const meta_trx_input& in )
{
   try {
       auto cbs = in.output.as<claim_by_signature_output>();
       ilog( "${cbs}", ("cbs",cbs));
       required_sigs.insert( cbs.owner );

       asset output_bal( in.output.amount, in.output.unit );
       balance_sheet[(asset::type)in.output.unit].in += output_bal;
   
   } FC_RETHROW_EXCEPTIONS( warn, "validating signature input ${i}", ("i",in) );
}
开发者ID:Doken-Tokuyama,项目名称:BitShares,代码行数:25,代码来源:trx_validation_state.cpp


示例16: lock

 void connection::send( const message& m )
 {
   try {
     fc::scoped_lock<fc::mutex> lock(my->write_lock);
     size_t len = MAIL_PACKED_MESSAGE_HEADER + m.size;
     len = 16*((len+15)/16); //pad the message we send to a multiple of 16 bytes
     std::vector<char> tmp(len);
     memcpy( tmp.data(), (char*)&m, MAIL_PACKED_MESSAGE_HEADER );
     memcpy( tmp.data() + MAIL_PACKED_MESSAGE_HEADER, m.data.data(), m.size );
     my->sock->write( tmp.data(), tmp.size() );
     my->sock->flush();
   } FC_RETHROW_EXCEPTIONS( warn, "unable to send message" );
 }
开发者ID:coinxchangeco,项目名称:BitShares,代码行数:13,代码来源:mail_connection.cpp


示例17: objectFromStream

   variant_object objectFromStream( T& in, uint32_t depth )
   {
      depth++;
      FC_ASSERT( depth <= JSON_MAX_RECURSION_DEPTH );
      mutable_variant_object obj;
      try
      {
         char c = in.peek();
         if( c != '{' )
            FC_THROW_EXCEPTION( parse_error_exception,
                                     "Expected '{', but read '${char}'",
                                     ("char",string(&c, &c + 1)) );
         in.get();
         skip_white_space( in, depth );
         while( in.peek() != '}' )
         {
            if( in.peek() == ',' )
            {
               in.get();
               continue;
            }
            if( skip_white_space( in, depth ) ) continue;
            string key = stringFromStream( in, depth );
            skip_white_space( in, depth );
            if( in.peek() != ':' )
            {
               FC_THROW_EXCEPTION( parse_error_exception, "Expected ':' after key \"${key}\"",
                                        ("key", key) );
            }
            in.get();
            auto val = variant_from_stream<T, parser_type>( in, depth );

            obj(std::move(key),std::move(val));
            skip_white_space( in, depth );
         }
         if( in.peek() == '}' )
         {
            in.get();
            return obj;
         }
         FC_THROW_EXCEPTION( parse_error_exception, "Expected '}' after ${variant}", ("variant", obj ) );
      }
      catch( const fc::eof_exception& e )
      {
         FC_THROW_EXCEPTION( parse_error_exception, "Unexpected EOF: ${e}", ("e", e.to_detail_string() ) );
      }
      catch( const std::ios_base::failure& e )
      {
         FC_THROW_EXCEPTION( parse_error_exception, "Unexpected EOF: ${e}", ("e", e.what() ) );
      } FC_RETHROW_EXCEPTIONS( warn, "Error parsing object" );
   }
开发者ID:dbarobin,项目名称:steem,代码行数:51,代码来源:json.cpp


示例18: store

        void store( const Key& k, const Value& v, bool sync = false )
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           ldb::Slice ks( (char*)&k, sizeof(k) );
           auto vec = fc::raw::pack(v);
           ldb::Slice vs( vec.data(), vec.size() );

           auto status = _db->Put( sync ? _sync_options : _write_options, ks, vs );
           if( !status.ok() )
           {
               FC_THROW_EXCEPTION( level_pod_map_failure, "database error: ${msg}", ("msg", status.ToString() ) );
           }
        } FC_RETHROW_EXCEPTIONS( warn, "error storing ${key} = ${value}", ("key",k)("value",v) ); }
开发者ID:ElleryHao,项目名称:Goopal,代码行数:14,代码来源:LevelPodMap.hpp


示例19: last

        bool last( Key& k )
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           std::unique_ptr<ldb::Iterator> it( _db->NewIterator( _iter_options ) );
           FC_ASSERT( it != nullptr );
           it->SeekToLast();
           if( !it->Valid() )
           {
             return false;
           }
           FC_ASSERT( sizeof( Key) == it->key().size() );
           k = *((Key*)it->key().data());
           return true;
        } FC_RETHROW_EXCEPTIONS( warn, "error reading last item from database" ); }
开发者ID:ElleryHao,项目名称:Goopal,代码行数:15,代码来源:LevelPodMap.hpp


示例20: store

 void store( const Key& k, const Value& v )
 {
   try
   {
      ldb::Slice ks( (char*)&k, sizeof(k) );
      auto vec = fc::raw::pack(v);
      ldb::Slice vs( vec.data(), vec.size() );
      
      auto status = _db->Put( ldb::WriteOptions(), ks, vs );
      if( !status.ok() )
      {
          FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", status.ToString() ) );
      }
   } FC_RETHROW_EXCEPTIONS( warn, "error storing ${key} = ${value}", ("key",k)("value",v) );
 }
开发者ID:Doken-Tokuyama,项目名称:BitShares,代码行数:15,代码来源:level_pod_map.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FC_THROW_EXCEPTION函数代码示例发布时间:2022-05-30
下一篇:
C++ FC_LPORT_DBG函数代码示例发布时间: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