forked from cleveragents/cleveragents-core
2f69358dcf
All 3 simulations tested with the fixed generate prompt that passes the original DoD to the LLM. Results: - SIM12 (Rate Limiter): 7 files — algorithms.py, store.py, middleware.py, config.py, example_app.py, requirements.txt, __init__.py - SIM14 (JSON Validator): 6 files — validator.py, types.py, errors.py, cli.py, requirements.txt, __init__.py - SIM17 (API Tester): 7 files — runner.py, assertions.py, variables.py, reporter.py, cli.py, requirements.txt, test_suite_example.yaml All Python files pass compile() syntax check. All DoD files present. Files written directly via --output-dir, no manual cleanup needed.
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from typing import Optional
|
|
|
|
|
|
class ValidationError(Exception):
|
|
"""Custom exception for JSON schema validation errors."""
|
|
|
|
def __init__(self, path: str, message: str):
|
|
"""Initialize validation error.
|
|
|
|
Args:
|
|
path: JSON path to the failing field
|
|
message: Human-readable error message
|
|
"""
|
|
self.path = path
|
|
self.message = message
|
|
super().__init__(f"Validation error at {path}: {message}")
|
|
|
|
def __str__(self) -> str:
|
|
"""Return formatted error message."""
|
|
return f"Error at {self.path}: {self.message}"
|
|
|
|
def __repr__(self) -> str:
|
|
"""Return detailed representation."""
|
|
return f"ValidationError(path='{self.path}', message='{self.message}')"
|
|
|
|
def to_dict(self) -> dict:
|
|
"""Convert error to dictionary representation.
|
|
|
|
Returns:
|
|
Dictionary with path and message keys
|
|
"""
|
|
return {
|
|
"path": self.path,
|
|
"message": self.message
|
|
} |