File size: 1,952 Bytes
4344b33 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | """
Custom exceptions for UVM TB Generator with structured error codes.
Industry-standard error taxonomy.
"""
from __future__ import annotations
class UVMGenError(Exception):
"""Base exception for all UVM TB Generator errors."""
code: str = "UNKNOWN_ERROR"
status_code: int = 500
details: str = ""
def __init__(self, message: str = "", details: str = "", status_code: int | None = None):
self.message = message or self.__doc__ or str(self.code)
self.details = details
if status_code is not None:
self.status_code = status_code
super().__init__(self.message)
def to_dict(self) -> dict:
return {
"error": self.code,
"message": self.message,
"details": self.details,
"status_code": self.status_code,
}
class SpecNotFoundError(UVMGenError):
code = "SPEC_NOT_FOUND"
status_code = 404
class SpecValidationError(UVMGenError):
code = "SPEC_VALIDATION_FAILED"
status_code = 422
class SpecParseError(UVMGenError):
code = "SPEC_PARSE_ERROR"
status_code = 422
class PipelineRunError(UVMGenError):
code = "PIPELINE_RUN_FAILED"
status_code = 500
class ModelNotTrainedError(UVMGenError):
code = "MODEL_NOT_TRAINED"
status_code = 400
class GenerationError(UVMGenError):
code = "GENERATION_FAILED"
status_code = 500
class SimulationError(UVMGenError):
code = "SIMULATION_FAILED"
status_code = 500
class SimulatorNotFoundError(UVMGenError):
code = "SIMULATOR_NOT_FOUND"
status_code = 400
class RegistryError(UVMGenError):
code = "REGISTRY_ERROR"
status_code = 500
class ConfigurationError(UVMGenError):
code = "CONFIGURATION_ERROR"
status_code = 400
class ProtocolNotSupportedError(UVMGenError):
code = "PROTOCOL_NOT_SUPPORTED"
status_code = 400
details = "Supported protocols: uart, spi, i2c, axi4lite, apb, wishbone"
|