BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
exceptions.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
30 #include <graphene/chain/types.hpp>
31 
32 #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \
33  FC_DECLARE_DERIVED_EXCEPTION( \
34  op_name ## _validate_exception, \
35  graphene::chain::operation_validate_exception, \
36  3040000 + 100 * operation::tag< op_name ## _operation >::value \
37  ) \
38  FC_DECLARE_DERIVED_EXCEPTION( \
39  op_name ## _evaluate_exception, \
40  graphene::chain::operation_evaluate_exception, \
41  3050000 + 100 * operation::tag< op_name ## _operation >::value \
42  )
43 
44 #define GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( op_name ) \
45  FC_IMPLEMENT_DERIVED_EXCEPTION( \
46  op_name ## _validate_exception, \
47  graphene::chain::operation_validate_exception, \
48  3040000 + 100 * operation::tag< op_name ## _operation >::value, \
49  #op_name "_operation validation exception" \
50  ) \
51  FC_IMPLEMENT_DERIVED_EXCEPTION( \
52  op_name ## _evaluate_exception, \
53  graphene::chain::operation_evaluate_exception, \
54  3050000 + 100 * operation::tag< op_name ## _operation >::value, \
55  #op_name "_operation evaluation exception" \
56  )
57 
58 #define GRAPHENE_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum ) \
59  FC_DECLARE_DERIVED_EXCEPTION( \
60  op_name ## _ ## exc_name, \
61  graphene::chain::op_name ## _validate_exception, \
62  3040000 + 100 * operation::tag< op_name ## _operation >::value \
63  + seqnum \
64  )
65 
66 #define GRAPHENE_IMPLEMENT_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
67  FC_IMPLEMENT_DERIVED_EXCEPTION( \
68  op_name ## _ ## exc_name, \
69  graphene::chain::op_name ## _validate_exception, \
70  3040000 + 100 * operation::tag< op_name ## _operation >::value \
71  + seqnum, \
72  msg \
73  )
74 
75 #define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum ) \
76  FC_DECLARE_DERIVED_EXCEPTION( \
77  op_name ## _ ## exc_name, \
78  graphene::chain::op_name ## _evaluate_exception, \
79  3050000 + 100 * operation::tag< op_name ## _operation >::value \
80  + seqnum \
81  )
82 
83 #define GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
84  FC_IMPLEMENT_DERIVED_EXCEPTION( \
85  op_name ## _ ## exc_name, \
86  graphene::chain::op_name ## _evaluate_exception, \
87  3050000 + 100 * operation::tag< op_name ## _operation >::value \
88  + seqnum, \
89  msg \
90  )
91 
92 #define GRAPHENE_TRY_NOTIFY( signal, ... ) \
93  try \
94  { \
95  signal( __VA_ARGS__ ); \
96  } \
97  catch( const graphene::chain::plugin_exception& e ) \
98  { \
99  elog( "Caught plugin exception: ${e}", ("e", e.to_detail_string() ) ); \
100  throw; \
101  } \
102  catch( ... ) \
103  { \
104  wlog( "Caught unexpected exception in plugin" ); \
105  }
106 
107 namespace graphene { namespace chain {
108 
110 
111  FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000 )
112  FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000 )
114  FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000 )
115  FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000 )
116  FC_DECLARE_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000 )
117  FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000 )
118  FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000 )
119  FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000 )
120  FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000 )
121 
122  FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006 )
123 
124  FC_DECLARE_DERIVED_EXCEPTION( duplicate_transaction, transaction_process_exception, 3030001 )
125 
126  FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001 )
127 
129  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1 )
130  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( to_account_not_whitelisted, transfer, 2 )
131  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( restricted_transfer_asset, transfer, 3 )
132 
135  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( market_not_whitelisted, limit_order_create, 2 )
137  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( selling_asset_unauthorized, limit_order_create, 4 )
138  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( receiving_asset_unauthorized, limit_order_create, 5 )
140 
141  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( limit_order_cancel );
142  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( nonexist_order, limit_order_cancel, 1 )
143  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( owner_mismatch, limit_order_cancel, 2 )
144 
145  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( call_order_update );
146  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1 )
147 
150  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_create, 2 )
151  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( buyback_incorrect_issuer, account_create, 3 )
152  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( buyback_already_exists, account_create, 4 )
153  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( buyback_too_many_markets, account_create, 5 )
154 
155  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_update );
156  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_update, 1 )
157  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_update, 2 )
158 
159  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_whitelist );
160  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_upgrade );
161  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_transfer );
162  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_create );
163  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update );
164  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_bitasset );
165  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_feed_producers );
166  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_issue );
167 
168  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_reserve );
169  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( invalid_on_mia, asset_reserve, 1 )
170 
171  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_fund_fee_pool );
172  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_settle );
173  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_global_settle );
174  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_publish_feed );
175  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( committee_member_create );
176  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( witness_create );
177 
178  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( proposal_create );
179  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( review_period_required, proposal_create, 1 )
180  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( review_period_insufficient, proposal_create, 2 )
181 
182  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( proposal_update );
183  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( proposal_delete );
184  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_create );
185  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_update );
186  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_claim );
187  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_delete );
188  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( fill_order );
189  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( global_parameters_update );
190  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( vesting_balance_create );
191  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( vesting_balance_withdraw );
192  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( worker_create );
193  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( custom );
194  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( assert );
195 
196  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( balance_claim );
197  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( claimed_too_often, balance_claim, 1 )
198  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( invalid_claim_amount, balance_claim, 2 )
199  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( owner_mismatch, balance_claim, 3 )
200 
201  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( override_transfer );
202  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1 )
203 
204  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer );
205  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1 )
206 
207  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer_from_blind_operation )
208  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_fees_operation )
209  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation )
210  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation )
211  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation )
212  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_create_operation )
213  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_redeem_operation )
214  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_extend_operation )
215 
216  #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \
217  catch( const cause_type& e ) \
218  { throw( effect_type( e.what(), e.get_log() ) ); }
219 
220 } } // graphene::chain
#define FC_DECLARE_DERIVED_EXCEPTION(TYPE, BASE, CODE)
Definition: exception.hpp:226
#define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION(exc_name, op_name, seqnum)
Definition: exceptions.hpp:75
block validation exception operation validation exception utility method exception transaction_process_exception
Definition: exceptions.cpp:62
Definition: api.cpp:56
Defines exception&#39;s used by fc.
#define FC_DECLARE_EXCEPTION(TYPE, CODE)
Definition: exception.hpp:278
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS(transfer)