Skip to content

Commit

Permalink
expanded exceptions #2
Browse files Browse the repository at this point in the history
  • Loading branch information
inertia186 committed Oct 3, 2018
1 parent 474ffd7 commit b3fa464
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/steem/base_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ def self.build_error(error, context)
raise Steem::NonCanonicalSignatureError, "#{context}: #{error.message}", build_backtrace(error)
end

if error.message.include? 'RC. Please wait to transact, or power up STEEM.'
raise Steem::ResourceCreditsExceededError, "#{context}: #{error.message}", build_backtrace(error)
end

if error.message.include? 'gpo.available_account_subsidies >= STEEM_ACCOUNT_SUBSIDY_PRECISION'
raise Steem::AvailableAccountSubsidiesError, "#{context}: #{error.message}", build_backtrace(error)
end

if error.message.include? 'attempting to push a block that is too old'
raise Steem::BlockTooOldError, "#{context}: #{error.message}", build_backtrace(error)
end
Expand Down Expand Up @@ -122,6 +130,10 @@ def self.build_error(error, context)
raise Steem::UpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
end

if error.message.include? 'Unknown exception'
raise Steem::UnknownExceptionError, "#{context}: #{error.message}", build_backtrace(error)
end

if error.message.include? 'Bad or missing upstream response'
raise Steem::BadOrMissingUpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
end
Expand Down Expand Up @@ -190,6 +202,9 @@ class UnexpectedAssetError < ArgumentError; end
class TransactionExpiredError < BaseError; end
class DuplicateTransactionError < TransactionExpiredError; end
class NonCanonicalSignatureError < TransactionExpiredError; end
class ResourceCreditsError < BaseError; end
class ResourceCreditsExceededError < ResourceCreditsError; end
class AvailableAccountSubsidiesError < ResourceCreditsError; end
class BlockTooOldError < BaseError; end
class IrrelevantSignatureError < BaseError; end
class MissingAuthorityError < BaseError; end
Expand All @@ -201,6 +216,7 @@ class IncorrectRequestIdError < BaseError; end
class IncorrectResponseIdError < BaseError; end
class RemoteNodeError < BaseError; end
class UpstreamResponseError < RemoteNodeError; end
class UnknownExceptionError < RemoteNodeError; end
class RemoteDatabaseLockError < UpstreamResponseError; end
class PluginNotEnabledError < UpstreamResponseError; end
class BadOrMissingUpstreamResponseError < UpstreamResponseError; end
Expand Down
2 changes: 1 addition & 1 deletion lib/steem/mixins/retriable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Retriable

RETRYABLE_EXCEPTIONS = [
NonCanonicalSignatureError, IncorrectRequestIdError,
IncorrectResponseIdError, RemoteDatabaseLockError
IncorrectResponseIdError, RemoteDatabaseLockError, UnknownExceptionError
]

def can_retry?(e = nil)
Expand Down

0 comments on commit b3fa464

Please sign in to comment.