Added correct exception in Chunks parse output #346

Merged
d.zayakin merged 1 commit from d.zayakin/frostfs-testlib:add-correct-exception-in-chunks-parse-output into master 2025-01-14 06:22:31 +00:00

View file

@ -161,5 +161,5 @@ class ChunksOperations(interfaces.ChunksInterface):
def _parse_object_nodes(self, object_nodes: str) -> list[Chunk]:
parse_result = json.loads(object_nodes)
if parse_result.get("errors"):
raise parse_result["errors"]
raise RuntimeError(", ".join(parse_result["errors"]))
d.zayakin marked this conversation as resolved Outdated

Why ValueError?

Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError.

parse_result is not an argument of a function _parse_object_nodes.

also, there is no need to add more text to it.

it's just raise RuntimeError(", ".join(parse_result["errors"]))

Why `ValueError`? ``` Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError. ``` `parse_result` is not an argument of a function `_parse_object_nodes`. also, there is no need to add more text to it. it's just `raise RuntimeError(", ".join(parse_result["errors"]))`

Then why is it a RuntimeError? The mistake here is that we got some kind of value in the key at all, but it shouldn't be there.

Then why is it a RuntimeError? The mistake here is that we got some kind of value in the key at all, but it shouldn't be there.

Then why is it a RuntimeError? The mistake here is that we got some kind of value in the key at all, but it shouldn't be there.

RuntimeError
Raised when an error is detected that doesn’t fall in any of the other categories. The associated value is a string indicating what precisely went wrong.
> Then why is it a RuntimeError? The mistake here is that we got some kind of value in the key at all, but it shouldn't be there. ``` RuntimeError Raised when an error is detected that doesn’t fall in any of the other categories. The associated value is a string indicating what precisely went wrong. ```
return [Chunk(**chunk) for chunk in parse_result["data_objects"]]