BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
exceptions.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 BitShares Blockchain Foundation, 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 
27 
28 namespace graphene { namespace chain {
29 
30  // Internal exceptions
31 
32  FC_IMPLEMENT_DERIVED_EXCEPTION( internal_exception, chain_exception, 3990000, "internal exception" )
33 
34  GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" )
35  GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" )
36 
37 
38  // Public exceptions
39 
40  FC_IMPLEMENT_EXCEPTION( chain_exception, 3000000, "blockchain exception" )
41 
42  FC_IMPLEMENT_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000,
43  "database query exception" )
44  FC_IMPLEMENT_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000,
45  "block validation exception" )
47  "transaction processing exception" )
48  FC_IMPLEMENT_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000,
49  "operation validation exception" )
50  FC_IMPLEMENT_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000,
51  "operation evaluation exception" )
52  FC_IMPLEMENT_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000,
53  "utility method exception" )
54  FC_IMPLEMENT_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000,
55  "undo database exception" )
56  FC_IMPLEMENT_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000, "unlinkable block" )
57  FC_IMPLEMENT_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000, "black swan" )
58  FC_IMPLEMENT_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000, "plugin exception" )
59 
60  FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006, "insufficient feeds" )
61 
62  FC_IMPLEMENT_DERIVED_EXCEPTION( duplicate_transaction, transaction_process_exception, 3030001,
63  "duplicate transaction" )
64 
65  FC_IMPLEMENT_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001,
66  "there are no blocks to pop" )
67 
69  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" )
70  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( to_account_not_whitelisted, transfer, 2, "owner mismatch" )
71  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( restricted_transfer_asset, transfer, 3, "restricted transfer asset" )
72 
74  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( kill_unfilled, limit_order_create, 1,
75  "Killing limit order due to unable to fill" )
76  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( market_not_whitelisted, limit_order_create, 2,
77  "The market has not been whitelisted by the selling asset" )
78  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( market_blacklisted, limit_order_create, 3,
79  "The market has been blacklisted by the selling asset" )
80  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( selling_asset_unauthorized, limit_order_create, 4,
81  "The account is not allowed to transact the selling asset" )
82  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( receiving_asset_unauthorized, limit_order_create, 5,
83  "The account is not allowed to transact the receiving asset" )
84  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( insufficient_balance, limit_order_create, 6,
85  "Insufficient balance" )
86 
87  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_cancel );
88  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( nonexist_order, limit_order_cancel, 1, "Order does not exist" )
89  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( owner_mismatch, limit_order_cancel, 2, "Order owned by someone else" )
90 
91  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( call_order_update );
92  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1,
93  "Updating call order would trigger a margin call that cannot be fully filled" )
94 
96  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_create, 1, "Exceeds max authority fan-out" )
97  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_create, 2, "Auth account not found" )
98  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_incorrect_issuer, account_create, 3,
99  "Incorrect issuer specified for account" )
100  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_already_exists, account_create, 4,
101  "Cannot create buyback for asset which already has buyback" )
102  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_too_many_markets, account_create, 5, "Too many buyback markets" )
103 
104  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_update );
105  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_update, 1, "Exceeds max authority fan-out" )
106  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_update, 2, "Auth account not found" )
107 
108  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_whitelist );
109  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_upgrade );
110  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_transfer );
111  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_create );
112  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update );
113  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_bitasset );
114  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_feed_producers );
115  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_issue );
116 
117  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_reserve );
118  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_on_mia, asset_reserve, 1, "invalid on mia" )
119 
120  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_fund_fee_pool );
121  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_settle );
122  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_global_settle );
123  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_publish_feed );
124  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( committee_member_create );
125  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( witness_create );
126 
127  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_create );
128  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_required, proposal_create, 1, "review_period required" )
129  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_insufficient, proposal_create, 2,
130  "review_period insufficient" )
131 
132  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_update );
133  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_delete );
134  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_create );
135  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_update );
136  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_claim );
137  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_delete );
138  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( fill_order );
139  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( global_parameters_update );
140  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_create );
141  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_withdraw );
142  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( worker_create );
143  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( custom );
144  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( assert );
145 
146  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( balance_claim );
147  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( claimed_too_often, balance_claim, 1, "balance claimed too often" )
148  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_claim_amount, balance_claim, 2, "invalid claim amount" )
149  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( owner_mismatch, balance_claim, 3, "owner mismatch" )
150 
151  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( override_transfer );
152  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1, "not permitted" )
153 
154  GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( blind_transfer );
155  GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1,
156  "Attempting to claim an unknown prior commitment" );
157 
158  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer_from_blind_operation )
159  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_fees_operation )
160  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( bid_collateral_operation )
161  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_pool_operation )
162  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_issuer_operation )
163  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_create_operation )
164  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_redeem_operation )
165  //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_extend_operation )
166 
167  #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \
168  catch( const cause_type& e ) \
169  { throw( effect_type( e.what(), e.get_log() ) ); }
170 
171 } } // graphene::chain
#define GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION(exc_name, seqnum, msg)
#define FC_IMPLEMENT_EXCEPTION(TYPE, CODE, WHAT)
Definition: exception.hpp:281
Identifies a weighted set of keys and accounts that must approve operations.
Definition: authority.hpp:34
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION(kill_unfilled, limit_order_create, 1,"Killing limit order due to unable to fill") GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION(market_not_whitelisted
block validation exception operation validation exception utility method exception transaction_process_exception
Definition: exceptions.cpp:62
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:56
fc::static_variant< transfer_operation, limit_order_create_operation, limit_order_cancel_operation, call_order_update_operation, fill_order_operation, account_create_operation, account_update_operation, account_whitelist_operation, account_upgrade_operation, account_transfer_operation, asset_create_operation, asset_update_operation, asset_update_bitasset_operation, asset_update_feed_producers_operation, asset_issue_operation, asset_reserve_operation, asset_fund_fee_pool_operation, asset_settle_operation, asset_global_settle_operation, asset_publish_feed_operation, witness_create_operation, witness_update_operation, proposal_create_operation, proposal_update_operation, proposal_delete_operation, withdraw_permission_create_operation, withdraw_permission_update_operation, withdraw_permission_claim_operation, withdraw_permission_delete_operation, committee_member_create_operation, committee_member_update_operation, committee_member_update_global_parameters_operation, vesting_balance_create_operation, vesting_balance_withdraw_operation, worker_create_operation, custom_operation, assert_operation, balance_claim_operation, override_transfer_operation, transfer_to_blind_operation, blind_transfer_operation, transfer_from_blind_operation, asset_settle_cancel_operation, asset_claim_fees_operation, fba_distribute_operation, bid_collateral_operation, execute_bid_operation, asset_claim_pool_operation, asset_update_issuer_operation, htlc_create_operation, htlc_redeem_operation, htlc_redeemed_operation, htlc_extend_operation, htlc_refund_operation, custom_authority_create_operation, custom_authority_update_operation, custom_authority_delete_operation, ticket_create_operation, ticket_update_operation >
groups operations that should be applied atomically
Definition: transaction.hpp:68
FC_IMPLEMENT_DERIVED_EXCEPTION(database_query_exception, chain_exception, 3010000,"database query exception") FC_IMPLEMENT_DERIVED_EXCEPTION(block_validate_exception
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS(limit_order_create)