Page MenuHomeSoftware Heritage

D4506.diff
No OneTemporary

D4506.diff

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

Mime Type
text/plain
Expires
Tue, Dec 17, 10:10 PM (2 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225946

Event Timeline