BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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_update );
142  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( nonexist_order, limit_order_update, 1 )
143  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( owner_mismatch, limit_order_update, 2 )
144 
145  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( limit_order_cancel );
146  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( nonexist_order, limit_order_cancel, 1 )
147  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( owner_mismatch, limit_order_cancel, 2 )
148 
149  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( call_order_update );
150  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1 )
151 
154  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_create, 2 )
155  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( buyback_incorrect_issuer, account_create, 3 )
156  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( buyback_already_exists, account_create, 4 )
157  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( buyback_too_many_markets, account_create, 5 )
158 
159  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_update );
160  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_update, 1 )
161  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_update, 2 )
162 
163  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_whitelist );
164  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_upgrade );
165  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_transfer );
166  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_create );
167  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update );
168  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_bitasset );
169  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_feed_producers );
170  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_issue );
171 
172  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_reserve );
173  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( invalid_on_mia, asset_reserve, 1 )
174 
175  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_fund_fee_pool );
176  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_settle );
177  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_global_settle );
178  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_publish_feed );
179  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( committee_member_create );
180  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( witness_create );
181 
182  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( proposal_create );
183  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( review_period_required, proposal_create, 1 )
184  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( review_period_insufficient, proposal_create, 2 )
185 
186  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( proposal_update );
187  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( proposal_delete );
188  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_create );
189  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_update );
190  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_claim );
191  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( withdraw_permission_delete );
192  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( fill_order );
193  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( global_parameters_update );
194  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( vesting_balance_create );
195  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( vesting_balance_withdraw );
196  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( worker_create );
197  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( custom );
198  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( assert );
199 
200  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( balance_claim );
201  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( claimed_too_often, balance_claim, 1 )
202  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( invalid_claim_amount, balance_claim, 2 )
203  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( owner_mismatch, balance_claim, 3 )
204 
205  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( override_transfer );
206  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1 )
207 
208  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer );
209  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1 )
210 
211  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer_from_blind_operation )
212  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_fees_operation )
213  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation )
214  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation )
215  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation )
216  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_create_operation )
217  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_redeem_operation )
218  //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_extend_operation )
219 
220  GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( liquidity_pool_exchange );
221  GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unfillable_price, liquidity_pool_exchange, 1 )
222 
223  #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \
224  catch( const cause_type& e ) \
225  { throw( effect_type( e.what(), e.get_log() ) ); }
226 
227 } } // graphene::chain
fee_schedule.hpp
FC_DECLARE_DERIVED_EXCEPTION
#define FC_DECLARE_DERIVED_EXCEPTION(TYPE, BASE, CODE)
Definition: exception.hpp:226
graphene::chain::GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS(transfer)
operations.hpp
graphene::chain::transaction_process_exception
block validation exception operation validation exception utility method exception transaction_process_exception
Definition: exceptions.cpp:62
graphene::chain::account_create
account_create
Definition: exceptions.cpp:104
FC_DECLARE_EXCEPTION
#define FC_DECLARE_EXCEPTION(TYPE, CODE)
Definition: exception.hpp:278
exception.hpp
Defines exception's used by fc.
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION
#define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION(exc_name, op_name, seqnum)
Definition: exceptions.hpp:75
types.hpp
graphene::chain::chain_exception
chain_exception
Definition: exceptions.cpp:44
graphene::chain::limit_order_create
limit_order_create
Definition: exceptions.cpp:76
exceptions.hpp
graphene
Definition: api.cpp:48