Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123116
D4506.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D4506.diff
View Options
diff --git a/swh/deposit/api/common.py b/swh/deposit/api/common.py
--- a/swh/deposit/api/common.py
+++ b/swh/deposit/api/common.py
@@ -61,7 +61,7 @@
METHOD_NOT_ALLOWED,
NOT_FOUND,
PARSING_ERROR,
- BadRequestError,
+ DepositError,
ParserError,
make_error_dict,
make_error_response,
@@ -652,7 +652,7 @@
update scenario provides one)
Raises:
- BadRequestError in case of incorrect inputs from the deposit client
+ DepositError in case of incorrect inputs from the deposit client
(e.g. functionally invalid metadata, ...)
Returns:
@@ -662,7 +662,8 @@
metadata_ok, error_details = check_metadata(metadata)
if not metadata_ok:
assert error_details, "Details should be set when a failure occurs"
- raise BadRequestError(
+ raise DepositError(
+ BAD_REQUEST,
"Functional metadata checks failure",
convert_status_detail(error_details),
)
@@ -806,8 +807,8 @@
swhid, swhid_ref, depo, depo_request = self._store_metadata_deposit(
deposit, swhid, metadata, raw_metadata
)
- except BadRequestError as bad_request_error:
- return bad_request_error.to_dict()
+ except DepositError as deposit_error:
+ return deposit_error.to_dict()
deposit.status = DEPOSIT_STATUS_LOAD_SUCCESS
if isinstance(swhid_ref, SWHID):
diff --git a/swh/deposit/api/edit.py b/swh/deposit/api/edit.py
--- a/swh/deposit/api/edit.py
+++ b/swh/deposit/api/edit.py
@@ -11,7 +11,7 @@
from swh.model.identifiers import parse_swhid
from ..config import DEPOSIT_STATUS_LOAD_SUCCESS
-from ..errors import BAD_REQUEST, BadRequestError, ParserError, make_error_dict
+from ..errors import BAD_REQUEST, DepositError, ParserError, make_error_dict
from ..parsers import SWHAtomEntryParser, SWHMultiPartParser
from .common import APIDelete, APIPut, ParsedRequestHeaders
@@ -133,8 +133,8 @@
_, _, deposit, deposit_request = self._store_metadata_deposit(
deposit, parse_swhid(swhid), metadata, raw_metadata, deposit.origin_url,
)
- except BadRequestError as bad_request_error:
- return bad_request_error.to_dict()
+ except DepositError as deposit_error:
+ return deposit_error.to_dict()
return {
"deposit_id": deposit.id,
diff --git a/swh/deposit/errors.py b/swh/deposit/errors.py
--- a/swh/deposit/errors.py
+++ b/swh/deposit/errors.py
@@ -166,13 +166,13 @@
)
-class BadRequestError(ValueError):
- """Represents a bad input from the deposit client
+class DepositError(ValueError):
+ """Represents an error that should be reported to the client
"""
- def __init__(self, summary, verbose_description):
- self.key = BAD_REQUEST
+ def __init__(self, key, summary, verbose_description):
+ self.key = key
self.summary = summary
self.verbose_description = verbose_description
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 17, 10:10 PM (2 d, 15 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225946
Attached To
D4506: Generalize BadRequestError to be a DepositError.
Event Timeline
Log In to Comment