Exception: Steem::BaseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/steem/base_error.rb

Class Method Summary collapse

Instance Method Summary collapse

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

Raises:



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.message == 'Unable to acquire database lock'
    raise Steem::RemoteDatabaseLockError, error.message, build_backtrace(error)
  end
  
  if error.message.include? 'Internal Error'
    raise Steem::RemoteNodeError, error.message, build_backtrace(error)
  end
  
  if error.message.include? 'Server error'
    raise Steem::RemoteNodeError, error.message, build_backtrace(error)
  end
  
  if error.message.include? 'plugin not enabled'
    raise Steem::PluginNotEnabledError, error.message, build_backtrace(error)
  end
  
  if error.message.include? 'argument'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Invalid params'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.start_with? 'Bad Cast:'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'prefix_len'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Parse Error'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'unknown key'
    raise Steem::ArgumentError, "#{context}: #{error.message} (or content has been deleted)", build_backtrace(error)
  end
  
  if error.message.include? 'Comment is not in account\'s comments'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Could not find comment'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'unable to convert ISO-formatted string to fc::time_point_sec'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Input data have to treated as object.'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'base.amount > share_type(0)'
    raise Steem::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'blk->transactions.size() > itr->trx_in_block'
    raise Steem::VirtualOperationsNotAllowedError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'A transaction must have at least one operation'
    raise Steem::EmptyTransactionError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'transaction expiration exception'
    raise Steem::TransactionExpiredError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Duplicate transaction check failed'
    raise Steem::DuplicateTransactionError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'signature is not canonical'
    raise Steem::NonCanonicalSignatureError, "#{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
  
  if error.message.include? 'irrelevant signature'
    raise Steem::IrrelevantSignatureError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'missing required posting authority'
    raise Steem::MissingPostingAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'missing required active authority'
    raise Steem::MissingActiveAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'missing required owner authority'
    raise Steem::MissingOwnerAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'missing required other authority'
    raise Steem::MissingOtherAuthorityError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Upstream response error'
    raise Steem::UpstreamResponseError, "#{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
  
  if error.message.include? 'operator has disabled operation indexing by transaction_id'
    raise Steem::TransactionIndexDisabledError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'is_valid_account_name'
    raise Steem::InvalidAccountError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include?('Method') && error.message.include?(' does not exist.')
    raise Steem::UnknownMethodError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Invalid operation name'
    raise Steem::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message =~ /Invalid object name: .+_operation/
    raise Steem::UnknownOperationError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Author not found'
    raise Steem::AuthorNotFoundError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? ' != fc::time_point_sec::maximum()'
    raise Steem::ReachedMaximumTimeError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Cannot transfer a negative amount (aka: stealing)'
    raise Steem::TheftError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'Must transfer a nonzero amount'
    raise Steem::NonZeroRequiredError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  if error.message.include? 'is_asset_type'
    raise Steem::UnexpectedAssetError, "#{context}: #{error.message}", build_backtrace(error)
  end
  
  puts JSON.pretty_generate(error) if ENV['DEBUG']
  raise UnknownError, "#{context}: #{error.message}", build_backtrace(error)
end

Instance Method Details

#to_sObject



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