Skip to content

Commit b0c8246

Browse files
committed
Add cleaner errors for unsuccessful faucet transactions
1 parent 1c612b2 commit b0c8246

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

contrib/signet/getcoins.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,15 @@
4848
except:
4949
print('Unexpected error when contacting faucet:', sys.exc_info()[0])
5050
exit()
51-
print(res.text)
51+
52+
# Display the output as per the returned status code
53+
if res:
54+
# When the return code is in between 200 and 400 i.e. successful
55+
print(res.text)
56+
elif res.status_code == 404:
57+
print('The specified faucet URL does not exist. Please check for any server issues/typo.')
58+
elif res.status_code == 429:
59+
print('The script does not allow for repeated transactions as the global faucet is rate-limitied to 1 request/IP/day. You can access the faucet website to get more coins manually')
60+
else:
61+
print(f'Returned Error Code {res.status_code}\n{res.text}\n')
62+
print('Please check the provided arguments for their validity and/or any possible typo.')

0 commit comments

Comments
 (0)