Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion blockcypher/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@
'''


class RateLimitError(RuntimeError):
class BlockcypherAPIError(Exception):
pass


class RateLimitError(BlockcypherAPIError):
''' Raised when the library makes too many API calls '''
pass


class TransactionNotFoundError(BlockcypherAPIError):
pass


def get_valid_json(request, allow_204=False):
if request.status_code == 429:
raise RateLimitError('Status Code 429', request.text)
Expand Down Expand Up @@ -464,6 +472,10 @@ def get_transaction_details(tx_hash, coin_symbol='btc', limit=None, tx_input_off
# format this string as a datetime object
response_dict['received'] = parser.parse(response_dict['received'])

if "error" in response_dict:
if response_dict["error"].startswith("Transaction") and response_dict["error"].endswith("not found."):
raise TransactionNotFoundError(response_dict["error"])

return response_dict


Expand Down