Skip to content

Commit 7e67fd2

Browse files
committed
feat: improved error handling
1 parent 45cd6b7 commit 7e67fd2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/handler.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def upload_file_to_uploadthing(
109109
)
110110
presigned_response.raise_for_status()
111111

112+
# Add response content logging
113+
print(f"Presigned response status: {presigned_response.status_code}")
114+
print(f"Presigned response content: {presigned_response.text}")
115+
112116
presigned = presigned_response.json()["data"][0]
113117
upload_url = presigned["url"]
114118
fields = presigned["fields"]
@@ -117,13 +121,20 @@ def upload_file_to_uploadthing(
117121
files = {"file": file_content}
118122
upload_response = requests.post(upload_url, data=fields, files=files)
119123
upload_response.raise_for_status()
124+
125+
# Add upload response logging
126+
print(f"Upload response status: {upload_response.status_code}")
127+
print(f"Upload response content: {upload_response.text}")
120128

121129
print(f"File uploaded successfully: {presigned['fileUrl']}")
122130
return presigned_response, upload_response, new_file_name
123131

124132
except Exception as e:
125133
last_error = e
126134
print(f"Upload attempt {attempt + 1} failed: {str(e)}")
135+
# Add more detailed error information
136+
if isinstance(e, requests.exceptions.RequestException):
137+
print(f"Request error details: {e.response.text if e.response else 'No response'}")
127138
attempt += 1
128139

129140
raise last_error
@@ -214,7 +225,7 @@ def generate(input):
214225

215226
return {
216227
"result": video_url,
217-
"status": "DONE"
228+
"status": "SUCCESS"
218229
}
219230
except Exception as e:
220231
print(f"Upload failed: {str(e)}")
@@ -226,7 +237,9 @@ def generate(input):
226237
except Exception as e:
227238
print(f"Generation failed: {str(e)}")
228239
return {
229-
"result": f"FAILED: {str(e)}",
240+
"status": "ERROR",
241+
"error": str(e),
242+
"result": None
230243
}
231244

232245

0 commit comments

Comments
 (0)