Skip to content

Commit

Permalink
feat: improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPietrusky committed Dec 20, 2024
1 parent 45cd6b7 commit 7e67fd2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def upload_file_to_uploadthing(
)
presigned_response.raise_for_status()

# Add response content logging
print(f"Presigned response status: {presigned_response.status_code}")
print(f"Presigned response content: {presigned_response.text}")

presigned = presigned_response.json()["data"][0]
upload_url = presigned["url"]
fields = presigned["fields"]
Expand All @@ -117,13 +121,20 @@ def upload_file_to_uploadthing(
files = {"file": file_content}
upload_response = requests.post(upload_url, data=fields, files=files)
upload_response.raise_for_status()

# Add upload response logging
print(f"Upload response status: {upload_response.status_code}")
print(f"Upload response content: {upload_response.text}")

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

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

raise last_error
Expand Down Expand Up @@ -214,7 +225,7 @@ def generate(input):

return {
"result": video_url,
"status": "DONE"
"status": "SUCCESS"
}
except Exception as e:
print(f"Upload failed: {str(e)}")
Expand All @@ -226,7 +237,9 @@ def generate(input):
except Exception as e:
print(f"Generation failed: {str(e)}")
return {
"result": f"FAILED: {str(e)}",
"status": "ERROR",
"error": str(e),
"result": None
}


Expand Down

0 comments on commit 7e67fd2

Please sign in to comment.