Features: 1) Add detailed traceback in error response for DEBUG mode; 2) Include received encoded_uuid in server error responses for better debugging;
Fixes: 1) Update error responses to use camelized keys consistently; Extra: 1) Add missing traceback import; 2) Improve error handling for digital asset downloads;
This commit is contained in:
parent
e7bfa87e74
commit
cbd72f10b8
1 changed files with 10 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
import uuid as uuid_module
|
import uuid as uuid_module
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -491,15 +492,21 @@ def download_digital_asset_view(request, *args, **kwargs):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
except BadRequest as e:
|
except BadRequest as e:
|
||||||
return JsonResponse({"error": str(e)}, status=400)
|
return JsonResponse(camelize({"error": str(e)}), status=400)
|
||||||
|
|
||||||
except DigitalAssetDownload.DoesNotExist:
|
except DigitalAssetDownload.DoesNotExist:
|
||||||
return JsonResponse({"error": "Digital asset not found"}, status=404)
|
return JsonResponse(camelize({"error": "Digital asset not found"}), status=404)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
capture_exception(e)
|
capture_exception(e)
|
||||||
return JsonResponse(
|
return JsonResponse(
|
||||||
{"error": "An error occurred while trying to download the digital asset"},
|
camelize(
|
||||||
|
{
|
||||||
|
"error": "An error occurred while trying to download the digital asset",
|
||||||
|
"traceback": traceback.format_exc() if settings.DEBUG else None,
|
||||||
|
"received": {"encoded_uuid": kwargs.get("encoded_uuid", "")},
|
||||||
|
}
|
||||||
|
),
|
||||||
status=500,
|
status=500,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue