Exception: DPay::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- DPay::BaseError
- Defined in:
- lib/dpay/base_error.rb
Direct Known Subclasses
ArgumentError, BlockTooOldError, IncorrectRequestIdError, IncorrectResponseIdError, IrrelevantSignatureError, JsonRpcBatchMaximumSizeExceededError, MissingAuthorityError, NotAppBaseError, RemoteNodeError, TooManyRetriesError, TooManyTimeoutsError, TransactionExpiredError, TransactionIndexDisabledError, TypeError, UnknownApiError, UnknownError, UnknownMethodError, UnknownOperationError, UnsupportedChainError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(error = nil, cause = nil) ⇒ BaseError
constructor
A new instance of BaseError.
- #to_s ⇒ Object
Constructor Details
#initialize(error = nil, cause = nil) ⇒ BaseError
Returns a new instance of BaseError.
3 4 5 6 |
# File 'lib/dpay/base_error.rb', line 3 def initialize(error = nil, cause = nil) @error = error @cause = cause end |
Class Method Details
.build_error(error, context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/dpay/base_error.rb', line 16 def self.build_error(error, context) if error. == 'Unable to acquire database lock' raise DPay::RemoteDatabaseLockError, error., build_backtrace(error) end if error..include? 'Internal Error' raise DPay::RemoteNodeError.new, error., build_backtrace(error) end if error..include? 'Server error' raise DPay::RemoteNodeError.new, error., build_backtrace(error) end if error..include? 'plugin not enabled' raise DPay::PluginNotEnabledError, error., build_backtrace(error) end if error..include? 'argument' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid params' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..start_with? 'Bad Cast:' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'prefix_len' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Parse Error' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'unknown key' raise DPay::ArgumentError, "#{context}: #{error.} (or content has been deleted)", build_backtrace(error) end if error..include? 'Comment is not in account\'s comments' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Could not find comment' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'unable to convert ISO-formatted string to fc::time_point_sec' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Input data have to treated as object.' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'base.amount > share_type(0)' raise DPay::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'blk->transactions.size() > itr->trx_in_block' raise DPay::VirtualOperationsNotAllowedError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'A transaction must have at least one operation' raise DPay::EmptyTransactionError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'transaction expiration exception' raise DPay::TransactionExpiredError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Duplicate transaction check failed' raise DPay::DuplicateTransactionError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'signature is not canonical' raise DPay::NonCanonicalSignatureError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'attempting to push a block that is too old' raise DPay::BlockTooOldError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'irrelevant signature' raise DPay::IrrelevantSignatureError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required posting authority' raise DPay::MissingPostingAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required active authority' raise DPay::MissingActiveAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required owner authority' raise DPay::MissingOwnerAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required other authority' raise DPay::MissingOtherAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Upstream response error' raise DPay::UpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Bad or missing upstream response' raise DPay::BadOrMissingUpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'operator has disabled operation indexing by transaction_id' raise DPay::TransactionIndexDisabledError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'is_valid_account_name' raise DPay::InvalidAccountError, "#{context}: #{error.}", build_backtrace(error) end if error..include?('Method') && error..include?(' does not exist.') raise DPay::UnknownMethodError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid operation name' raise DPay::UnknownOperationError, "#{context}: #{error.}", build_backtrace(error) end if error. =~ /Invalid object name: .+_operation/ raise DPay::UnknownOperationError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Author not found' raise DPay::AuthorNotFoundError, "#{context}: #{error.}", build_backtrace(error) end if error..include? ' != fc::time_point_sec::maximum()' raise DPay::ReachedMaximumTimeError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Cannot transfer a negative amount (aka: stealing)' raise DPay::TheftError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Must transfer a nonzero amount' raise DPay::NonZeroRequiredError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'is_asset_type' raise DPay::UnexpectedAssetError, "#{context}: #{error.}", build_backtrace(error) end puts JSON.pretty_generate(error) if ENV['DEBUG'] raise UnknownError, "#{context}: #{error.}", build_backtrace(error) end |
Instance Method Details
#to_s ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/dpay/base_error.rb', line 8 def to_s detail = {} detail[:error] = @error if !!@error detail[:cause] = @cause if !!@cause JSON[detail] rescue detai.to_s end |