Raise helpful errors when event handler inputs/outputs are mistyped (#13470)
* Raise helpful errors when event handler inputs/outputs are mistyped
When an event handler receives a wrong-typed input or returns a wrong-typed
output, the error was raised deep inside a component's pre/postprocess method
and gave no indication of which component/argument was at fault.
Wrap the pre/postprocess calls in preprocess_data/postprocess_data so that any
exception is re-raised as a new ComponentProcessingError that identifies the
component index, component type, the expected type, the offending value, and
the event handler name, while chaining the original exception.
Fixes #3522
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Fix backend typecheck: access pre/postprocess via getattr
Block has no preprocess/postprocess attribute (those live on
components.Component), so resolve the method dynamically to satisfy ty.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>