Exception: Steem::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- Steem::BaseError
- Defined in:
- lib/steem/base_error.rb
Direct Known Subclasses
ArgumentError, BlockTooOldError, DeserializationError, IncorrectRequestIdError, IncorrectResponseIdError, IrrelevantSignatureError, JsonRpcBatchMaximumSizeExceededError, MissingAuthorityError, NotAppBaseError, RemoteNodeError, SerializationMismatchError, 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/steem/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/steem/base_error.rb', line 16 def self.build_error(error, context) if error. == 'Unable to acquire database lock' raise Steem::RemoteDatabaseLockError, error., build_backtrace(error) end if error..include? 'Internal Error' raise Steem::RemoteNodeError, error., build_backtrace(error) end if error..include? 'Server error' raise Steem::RemoteNodeError, error., build_backtrace(error) end if error..include? 'plugin not enabled' raise Steem::PluginNotEnabledError, error., build_backtrace(error) end if error..include? 'argument' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid params' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..start_with? 'Bad Cast:' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'prefix_len' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Parse Error' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'unknown key' raise Steem::ArgumentError, "#{context}: #{error.} (or content has been deleted)", build_backtrace(error) end if error..include? 'Comment is not in account\'s comments' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Could not find comment' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'unable to convert ISO-formatted string to fc::time_point_sec' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Input data have to treated as object.' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'base.amount > share_type(0)' raise Steem::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'blk->transactions.size() > itr->trx_in_block' raise Steem::VirtualOperationsNotAllowedError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'A transaction must have at least one operation' raise Steem::EmptyTransactionError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'transaction expiration exception' raise Steem::TransactionExpiredError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Duplicate transaction check failed' raise Steem::DuplicateTransactionError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'signature is not canonical' raise Steem::NonCanonicalSignatureError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'attempting to push a block that is too old' raise Steem::BlockTooOldError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'irrelevant signature' raise Steem::IrrelevantSignatureError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required posting authority' raise Steem::MissingPostingAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required active authority' raise Steem::MissingActiveAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required owner authority' raise Steem::MissingOwnerAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required other authority' raise Steem::MissingOtherAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Upstream response error' raise Steem::UpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Bad or missing upstream response' raise Steem::BadOrMissingUpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'operator has disabled operation indexing by transaction_id' raise Steem::TransactionIndexDisabledError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'is_valid_account_name' raise Steem::InvalidAccountError, "#{context}: #{error.}", build_backtrace(error) end if error..include?('Method') && error..include?(' does not exist.') raise Steem::UnknownMethodError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid operation name' raise Steem::UnknownOperationError, "#{context}: #{error.}", build_backtrace(error) end if error. =~ /Invalid object name: .+_operation/ raise Steem::UnknownOperationError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Author not found' raise Steem::AuthorNotFoundError, "#{context}: #{error.}", build_backtrace(error) end if error..include? ' != fc::time_point_sec::maximum()' raise Steem::ReachedMaximumTimeError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Cannot transfer a negative amount (aka: stealing)' raise Steem::TheftError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Must transfer a nonzero amount' raise Steem::NonZeroRequiredError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'is_asset_type' raise Steem::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/steem/base_error.rb', line 8 def to_s detail = {} detail[:error] = @error if !!@error detail[:cause] = @cause if !!@cause JSON[detail] rescue detail.to_s end |