mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-09 07:08:09 -05:00
fix(backend): Mark ValueError as known block errors (#11537)
### Changes 🏗️ Mark ValueError as known block errors ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan:
This commit is contained in:
@@ -601,14 +601,18 @@ class Block(ABC, Generic[BlockSchemaInputType, BlockSchemaOutputType]):
|
|||||||
async for output_name, output_data in self._execute(input_data, **kwargs):
|
async for output_name, output_data in self._execute(input_data, **kwargs):
|
||||||
yield output_name, output_data
|
yield output_name, output_data
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if not isinstance(ex, BlockError):
|
if isinstance(ex, BlockError):
|
||||||
raise BlockUnknownError(
|
raise ex
|
||||||
|
else:
|
||||||
|
raise (
|
||||||
|
BlockExecutionError
|
||||||
|
if isinstance(ex, ValueError)
|
||||||
|
else BlockUnknownError
|
||||||
|
)(
|
||||||
message=str(ex),
|
message=str(ex),
|
||||||
block_name=self.name,
|
block_name=self.name,
|
||||||
block_id=self.id,
|
block_id=self.id,
|
||||||
) from ex
|
) from ex
|
||||||
else:
|
|
||||||
raise ex
|
|
||||||
|
|
||||||
async def _execute(self, input_data: BlockInput, **kwargs) -> BlockOutput:
|
async def _execute(self, input_data: BlockInput, **kwargs) -> BlockOutput:
|
||||||
if error := self.input_schema.validate_data(input_data):
|
if error := self.input_schema.validate_data(input_data):
|
||||||
|
|||||||
Reference in New Issue
Block a user