Skip to content

Commit 3e96d4a

Browse files
committed
Add exception
1 parent db0d832 commit 3e96d4a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

caltechdata_api/caltechdata_write.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import copy
22
import json
3-
import os
3+
import os, sys
44

55
from requests import session
6+
from json.decoder import JSONDecodeError
67

78
from caltechdata_api import customize_schema
89

@@ -22,9 +23,12 @@ def send_s3(filepath, token, production=False):
2223

2324
# print(s3surl)
2425
# print(headers)
25-
response = c.get(s3surl, headers=headers)
26-
jresp = response.json()
27-
data = jresp["data"]
26+
try:
27+
response = c.get(s3surl, headers=headers)
28+
jresp = response.json()
29+
data = jresp["data"]
30+
except Exception:
31+
print(f"Incorrect access token: {response}")
2832

2933
bucket = jresp["bucket"]
3034
key = data["fields"]["key"]

0 commit comments

Comments
 (0)