Exception: Hive::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- Hive::BaseError
- Defined in:
- lib/hive/base_error.rb
Direct Known Subclasses
ArgumentError, BlockTooOldError, DeserializationError, IncorrectRequestIdError, IncorrectResponseIdError, IrrelevantSignatureError, JsonRpcBatchMaximumSizeExceededError, MissingAuthorityError, NotAppBaseError, RemoteInternalError, RemoteNodeError, RemoteServerError, 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/hive/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 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/hive/base_error.rb', line 16 def self.build_error(error, context) if error. == 'Unable to acquire database lock' raise Hive::RemoteDatabaseLockError, error., build_backtrace(error) end if error..include? 'Internal Error' raise Hive::RemoteInternalError, error., build_backtrace(error) end if error..include? 'Server error' raise Hive::RemoteServerError, error., build_backtrace(error) end if error..include?('plugin not enabled') || error..include?('Could not find API') raise Hive::PluginNotEnabledError, error., build_backtrace(error) end if error..include? 'Supported by hivemind' raise Hive::MethodNotEnabledError, error., build_backtrace(error) end if error..include? 'argument' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid params' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..start_with? 'Bad Cast:' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'prefix_len' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Parse Error' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'unknown key' raise Hive::ArgumentError, "#{context}: #{error.} (or content has been deleted)", build_backtrace(error) end if error..include? 'Comment is not in account\'s comments' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Could not find comment' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'unable to convert ISO-formatted string to fc::time_point_sec' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Input data have to treated as object.' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'base.amount > share_type(0)' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid parameter' raise Hive::ArgumentError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'blk->transactions.size() > itr->trx_in_block' raise Hive::VirtualOperationsNotAllowedError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'A transaction must have at least one operation' raise Hive::EmptyTransactionError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'transaction expiration exception' raise Hive::TransactionExpiredError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Duplicate transaction check failed' raise Hive::DuplicateTransactionError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'signature is not canonical' raise Hive::NonCanonicalSignatureError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'attempting to push a block that is too old' raise Hive::BlockTooOldError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'irrelevant signature' raise Hive::IrrelevantSignatureError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required posting authority' raise Hive::MissingPostingAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required active authority' raise Hive::MissingActiveAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required owner authority' raise Hive::MissingOwnerAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'missing required other authority' raise Hive::MissingOtherAuthorityError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Upstream response error' raise Hive::UpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Request Timeout' raise Hive::RequestTimeoutUpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Bad or missing upstream response' raise Hive::BadOrMissingUpstreamResponseError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'operator has disabled operation indexing by transaction_id' raise Hive::TransactionIndexDisabledError, "#{context}: #{error.}", build_backtrace(error) end if error..include?('Assert Exception:false: Account name ') && error..include?(' is not valid. Please follow the RFC 1035 rules.') raise Hive::InvalidAccountError, "#{context}: #{error.}", build_backtrace(error) end if error..include?('Method') && error..include?(' does not exist.') raise Hive::UnknownMethodError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Invalid operation name' raise Hive::UnknownOperationError, "#{context}: #{error.}", build_backtrace(error) end if error. =~ /Invalid object name: .+_operation/ raise Hive::UnknownOperationError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Author not found' raise Hive::AuthorNotFoundError, "#{context}: #{error.}", build_backtrace(error) end if error..include? ' != fc::time_point_sec::maximum()' raise Hive::ReachedMaximumTimeError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Cannot transfer a negative amount (aka: stealing)' raise Hive::TheftError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'Must transfer a nonzero amount' raise Hive::NonZeroRequiredError, "#{context}: #{error.}", build_backtrace(error) end if error..include? 'is_asset_type' raise Hive::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/hive/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 |