Skip to content

Commit 945ebb4

Browse files
committed
Add new error when the period is too large
1 parent 38318e5 commit 945ebb4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

licensing/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ def from_response(response):
8787

8888
if "Reseller" in obj and obj["Reseller"] != None:
8989
reseller = Reseller(**obj["Reseller"])
90-
90+
91+
try:
92+
datetime.datetime.fromtimestamp(obj["Expires"])
93+
except:
94+
raise ValueError("The expiration date cannot be converted to a datetime object. Please try setting the period to a lower value. Read more: https://github.com/Cryptolens/cryptolens-python/tree/master#the-expiration-date-cannot-be-converted-to-a-datetime-object-please-try-setting-the-period-to-a-lower-value")
95+
9196
return LicenseKey(obj["ProductId"], obj["ID"], obj["Key"], datetime.datetime.fromtimestamp(obj["Created"]),\
9297
datetime.datetime.fromtimestamp(obj["Expires"]), obj["Period"], obj["F1"], obj["F2"], \
9398
obj["F3"], obj["F4"],obj["F5"],obj["F6"], obj["F7"], \

0 commit comments

Comments
 (0)