MCPcopy
hub / github.com/pydantic/pydantic / error_dict

Function error_dict

pydantic/v1/error_wrappers.py:119–133  ·  view source on GitHub ↗
(exc: Exception, config: Type['BaseConfig'], loc: 'Loc')

Source from the content-addressed store, hash-verified

117
118
119def error_dict(exc: Exception, config: Type['BaseConfig'], loc: 'Loc') -> 'ErrorDict':
120 type_ = get_exc_type(exc.__class__)
121 msg_template = config.error_msg_templates.get(type_) or getattr(exc, 'msg_template', None)
122 ctx = exc.__dict__
123 if msg_template:
124 msg = msg_template.format(**ctx)
125 else:
126 msg = str(exc)
127
128 d: 'ErrorDict' = {'loc': loc, 'msg': msg, 'type': type_}
129
130 if ctx:
131 d['ctx'] = ctx
132
133 return d
134
135
136_EXC_TYPE_CACHE: Dict[Type[Exception], str] = {}

Callers 1

flatten_errorsFunction · 0.85

Calls 2

get_exc_typeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected