Skip to content

Commit 18be21d

Browse files
committed
Fix errors
1 parent 3314f16 commit 18be21d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/storage_reader.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def get_ethscription(tx_hash, block_tag: 'latest')
189189
l2_block_number: ethscription_data[7],
190190
l1_block_hash: '0x' + ethscription_data[8].unpack1('H*')
191191
}
192-
rescue => e
193-
Rails.logger.error "Failed to get ethscription #{tx_hash}: #{e.message}"
194-
Rails.logger.error e.backtrace.join("\n") if Rails.env.development?
192+
rescue EthRpcClient::ExecutionRevertedError => e
193+
# Contract reverted - ethscription doesn't exist
194+
Rails.logger.debug "Ethscription #{tx_hash} doesn't exist (contract reverted): #{e.message}"
195195
nil
196196
end
197197

@@ -214,10 +214,10 @@ def get_ethscription_content(tx_hash, block_tag: 'latest')
214214

215215
# Return the raw bytes content
216216
decoded[0]
217-
rescue => e
218-
Rails.logger.error "Failed to get ethscription content #{tx_hash}: #{e.message}"
219-
Rails.logger.error e.backtrace.join("\n") if Rails.env.development?
220-
raise e
217+
rescue EthRpcClient::ExecutionRevertedError => e
218+
# Contract reverted - ethscription doesn't exist
219+
Rails.logger.debug "Ethscription content #{tx_hash} doesn't exist (contract reverted): #{e.message}"
220+
nil
221221
end
222222

223223
def get_owner(token_id, block_tag: 'latest')
@@ -240,8 +240,9 @@ def get_owner(token_id, block_tag: 'latest')
240240
# Decode the result - ownerOf returns a single address
241241
decoded = Eth::Abi.decode(['address'], result)
242242
Eth::Address.new(decoded[0]).to_s
243-
rescue => e
244-
Rails.logger.error "Failed to get owner of #{token_id}: #{e.message}"
243+
rescue EthRpcClient::ExecutionRevertedError => e
244+
# Contract reverted - token doesn't exist
245+
Rails.logger.debug "Token #{token_id} doesn't exist (contract reverted): #{e.message}"
245246
nil
246247
end
247248

0 commit comments

Comments
 (0)